ruby-shell 2.11.1 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rsh +33 -6
  3. metadata +4 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ea3ed53a591708e2637c362c1286a489f75a6cc549d8d057b3b2352594225142
4
- data.tar.gz: 3fa6fbf94b9cea324a7b2f48ecd42858f44055bdd014b3604424b26551f3ba9e
3
+ metadata.gz: 8b242a4147fbf7ac84940b1e2bc7b292541e3d99a1a063a52efa899e737e1851
4
+ data.tar.gz: 9c1e5298b951b939c3b85ab8831215079c43331a80805bbebab5c0cb3def5c4b
5
5
  SHA512:
6
- metadata.gz: 677514dfac4853286598fcf60e0b8332ef89540b01aba2ec1b133b9352348c6a757cce46228d42f86073481c0663e2374c5d7ede28b7f8116b8b977fa141ca70
7
- data.tar.gz: f94f381747aff0afd4ef8adca14b8e589a9929806c332a159c25c0a5772aac9ccb6bf1969c3f8ebda502fdeb782574ebb60eb8e8d92ecb9cac9219f30fa565e5
6
+ metadata.gz: dfa2498cfa54eb2b36170848c24f55026e45dbfa4926c4367efb866c45508e24beb52f841efbc08be376a8b8e4f9e0ec772c45bed479c48f6e8533107dd2b47a
7
+ data.tar.gz: 899f55fc361186ac32ec1a3ccf62243003a3d500a04ac5c25138a767abbad47940116511dce00c58ec40bf97d37fc092a968f5a85ddaf1943afe307770fc3a38
data/bin/rsh CHANGED
@@ -8,7 +8,7 @@
8
8
  # Web_site: http://isene.com/
9
9
  # Github: https://github.com/isene/rsh
10
10
  # License: Public domain
11
- @version = "2.11.0" # Enhanced TAB completion with smart context-aware completion, frequency scoring, fuzzy matching, and more
11
+ @version = "2.12.0" # Extensible command completion system for git, apt, docker, systemctl, cargo, npm, gem, bundle
12
12
 
13
13
  # MODULES, CLASSES AND EXTENSIONS
14
14
  class String # Add coloring to strings (with escaping for Readline)
@@ -119,6 +119,18 @@ begin # Initialization
119
119
  @job_id = 0 # Job counter
120
120
  @ai_suggestion = nil # Store AI command suggestion
121
121
  @last_exit = 0 # Last command exit status
122
+ # Command completions for subcommands
123
+ @cmd_completions = {
124
+ "git" => %w[add bisect branch checkout clone commit diff fetch grep init log merge mv pull push rebase reset restore rm show stash status switch tag],
125
+ "apt" => %w[install remove update upgrade search show list autoremove purge],
126
+ "apt-get" => %w[install remove update upgrade dist-upgrade autoremove purge clean autoclean],
127
+ "docker" => %w[build run ps images pull push start stop restart rm rmi exec logs inspect network volume],
128
+ "systemctl" => %w[start stop restart reload status enable disable is-active is-enabled list-units],
129
+ "cargo" => %w[build run test check clean doc new init add search publish install update],
130
+ "npm" => %w[install uninstall update run build test start init publish],
131
+ "gem" => %w[install uninstall update list search build push],
132
+ "bundle" => %w[install update exec check config]
133
+ }
122
134
  def pre_cmd; end # User-defined function to be run BEFORE command execution
123
135
  def post_cmd; end # User-defined function to be run AFTER command execution
124
136
  end
@@ -136,6 +148,7 @@ end
136
148
  * Aliases (called nicks in rsh) - both for commands and general nicks
137
149
  * Syntax highlighting, matching nicks, system commands and valid dirs/files
138
150
  * Tab completions for nicks, system commands, command switches and dirs/files
151
+ * Smart context-aware tab completion for git, apt, docker, systemctl, cargo, npm, gem, bundle
139
152
  * Tab completion presents matches in a list to pick from
140
153
  * When you start to write a command, rsh will suggest the first match in the history and
141
154
  present that in "toned down" letters - press the arrow right key to accept the suggestion
@@ -484,12 +497,16 @@ def tab(type)
484
497
  type = "dirs_only"
485
498
  when "vim", "nano", "cat", "less", "more", "head", "tail", "file"
486
499
  type = "files_only"
487
- when "git"
488
- type = "git_subcommands" if cmd_parts.length == 1
489
500
  when "man", "info", "which", "whatis"
490
501
  type = "commands_only"
491
502
  when "export", "unset"
492
503
  type = "env_vars"
504
+ else
505
+ # Check if command has defined completions and we're on the first argument
506
+ if @cmd_completions.key?(last_cmd) && cmd_parts.length == 1
507
+ type = "cmd_subcommands"
508
+ @current_cmd = last_cmd
509
+ end
493
510
  end
494
511
  end
495
512
 
@@ -519,10 +536,10 @@ def tab(type)
519
536
  ex.prepend(*@nick.keys, *@gnick.keys)
520
537
  regex_flags = @completion_case_sensitive ? 0 : Regexp::IGNORECASE
521
538
  @tabarray = ex.select { |s| s =~ Regexp.new(@tabstr, regex_flags) }
522
- when "git_subcommands" # Git subcommands
523
- git_cmds = %w[add branch checkout clone commit diff fetch init log merge pull push rebase reset status tag]
539
+ when "cmd_subcommands" # Command-specific subcommands (git, apt, docker, etc.)
540
+ subcommands = @cmd_completions[@current_cmd] || []
524
541
  regex_flags = @completion_case_sensitive ? 0 : Regexp::IGNORECASE
525
- @tabarray = git_cmds.select { |cmd| cmd =~ Regexp.new(@tabstr, regex_flags) }
542
+ @tabarray = subcommands.select { |cmd| cmd =~ Regexp.new(@tabstr, regex_flags) }
526
543
  when "env_vars" # Environment variables
527
544
  env_vars = ENV.keys.map { |k| "$#{k}" }
528
545
  regex_flags = @completion_case_sensitive ? 0 : Regexp::IGNORECASE
@@ -754,6 +771,10 @@ def rshrc # Write updates to .rshrc
754
771
  conf += "@gnick = #{@gnick}\n"
755
772
  conf.sub!(/^@cmd_frequency.*(\n|$)/, "")
756
773
  conf += "@cmd_frequency = #{@cmd_frequency}\n"
774
+ # Only write @cmd_completions if user has customized it
775
+ unless conf =~ /^@cmd_completions\s*=/
776
+ # Don't write default completions to avoid cluttering .rshrc
777
+ end
757
778
  conf.sub!(/^@history.*(\n|$)/, "")
758
779
  # Ensure history is properly formatted as valid Ruby array
759
780
  begin
@@ -831,6 +852,12 @@ def help
831
852
  right_col << "@ <question> AI text response"
832
853
  right_col << "@@ <request> AI command → prompt"
833
854
  right_col << ""
855
+ right_col << "SMART COMPLETIONS:".c(@c_prompt).b
856
+ right_col << "git <TAB> Git subcommands"
857
+ right_col << "apt/docker <TAB> Command options"
858
+ right_col << "Supports: git, apt, docker,"
859
+ right_col << "systemctl, cargo, npm, gem"
860
+ right_col << ""
834
861
  right_col << "EXPANSIONS:".c(@c_prompt).b
835
862
  right_col << "~ Home directory"
836
863
  right_col << "$VAR, ${VAR} Environment var"
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.1
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-04 00:00:00.000000000 Z
11
+ date: 2025-10-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
14
14
  history, syntax highlighting, theming, auto-cd, auto-opening files and more. UPDATE
15
- v2.11.1: Critical bugfix for nick persistence - nicks now save correctly to .rshrc
16
- without duplication when file doesn''t end with newline.'
15
+ v2.12.0: Extensible command completion system - smart tab completion for git, apt,
16
+ docker, systemctl, cargo, npm, gem, bundle with easy customization.'
17
17
  email: g@isene.com
18
18
  executables:
19
19
  - rsh