ruby-shell 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -4
  3. data/bin/rsh +13 -4
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42d9cc67e267cc950508cd413c920a948594343c05eb7908f684db4c5994d808
4
- data.tar.gz: 9bec180e3d91fd5867f725cc397531c37aa62c7097f349168abf338dfe94428b
3
+ metadata.gz: beb9449aa1999b4050dc9fc33e6bd34cfd72e53298f9a30260cdd7326c0c11f3
4
+ data.tar.gz: dbcf1ce70ae0a19d50a09fa5c28a43b83e6cfc67df6ebe67073994daa2721d8e
5
5
  SHA512:
6
- metadata.gz: aca12ee80c5eb1e4e8f1889c0c580e4f8be9c58f542fe593c30ff76aebf29777b2b88e68915c24bb6f64a3aefc2c52865dcc952b3eee89aecb842765acce0bb1
7
- data.tar.gz: 963d434b4670828f1989957db7ddf921cbafc4b39decd45a8f1f23a1e3f9be7dc1811b7b0eb4cc608c2676bdf828ef4337a0af246876720f83c87894ef725144
6
+ metadata.gz: 8c11546df1ddae55bea7cceab32b3084398a5b87bd32c4fa815e41ec8f236bdcb197af2c03e66fffe5dd7d9365d1936409066301d4d7941d5022f95c5f6b555c
7
+ data.tar.gz: 77838d06aebc6b9c92009f789cfe45666febce20aa5aaf7b90bbbb1c15c38a9acfba32c3a98e6c0bdf9218350987bd1cbd3f09787013fd40fc9e7f810f8afda0
data/README.md CHANGED
@@ -21,13 +21,13 @@ Or simply `gem install ruby-shell`.
21
21
  * Config file (`.rshrc`) updates on exit
22
22
  * Set of simple rsh specific commands like `nick`, `nick?`, `history` and `rmhistory`
23
23
  * rsh specific commands and full set of Ruby commands available via `:command`
24
- * All colors are themable in `.rshrc`
24
+ * All colors are themeable in `.rshrc`
25
25
 
26
26
  ## Nicks
27
- Add command nicks (aliases) with `:nick "some_nick = some_command"`, e.g. `:nick "ls = ls --color"`. Add general nicks that will substitute anything on a command line (not just commands) like this `:gnick "some_gnick = some_command"`, e.g. `:gnick "x = /home/user/somewhere"`. List (g)nicks with `:nicks?`. Remove a nick with `:nick "-some_command"`, e.g. `:nick "-ls"` to remove an `ls` nick. Same for gnicks.
27
+ Add command nicks (aliases) with `:nick "some_nick = some_command"`, e.g. `:nick "ls = ls --color"`. Add general nicks that will substitute anything on a command line (not just commands) like this `:gnick "some_gnick = some_command"`, e.g. `:gnick "x = /home/user/somewhere"`. List (g)nicks with `:nick?`. Remove a nick with `:nick "-some_command"`, e.g. `:nick "-ls"` to remove an `ls` nick. Same for gnicks.
28
28
 
29
29
  ## Tab completion
30
- You can tab complete almost anything. Hitting `TAB` will try to complete in this priority: nicks, gnicks, commands, dirs/files. Hitting `TAB`after a `-` will list the command switches for the preceeding command with a short explanation (from the command's --help), like this `ls -`(`TAB`) will list all the switches/options for the `ls` command.
30
+ You can tab complete almost anything. Hitting `TAB` will try to complete in this priority: nicks, gnicks, commands, dirs/files. Hitting `TAB`after a `-` will list the command switches for the preceding command with a short explanation (from the command's --help), like this `ls -`(`TAB`) will list all the switches/options for the `ls` command.
31
31
 
32
32
  ## Syntax highlighting
33
33
  rsh will highlight nicks, gnicks, commands and dirs/files as they are written on the command line.
@@ -45,5 +45,11 @@ Variable | Description
45
45
  `@c_tabselect` | Color for selected tabcompleted item
46
46
  `@c_taboption` | Color for unselected tabcompleted item
47
47
 
48
- # License and copyringht
48
+ # Enter the world of Ruby
49
+ By entering `:some-ruby-command` you have full access to the Ruby universe right from your command line. You can do anything from `:puts 2 + 13` or `:if 0.7 > Math::sin(34) then puts "OK" end` or whatever tickles you fancy.
50
+
51
+ # Not yet implemented
52
+ Lots. Of. Stuff.
53
+
54
+ # License and copyright
49
55
  Forget it.
data/bin/rsh CHANGED
@@ -14,7 +14,7 @@
14
14
  # for any damages resulting from its use. Further, I am under no
15
15
  # obligation to maintain or extend this software. It is provided
16
16
  # on an 'as is' basis without any expressed or implied warranty.
17
- @version = "0.1"
17
+ @version = "0.3"
18
18
 
19
19
  # MODULES, CLASSES AND EXTENSIONS
20
20
  class String # Add coloring to strings (with escaping for Readline)
@@ -97,6 +97,7 @@ end
97
97
  begin # Requires
98
98
  require 'etc'
99
99
  require 'io/console'
100
+ require 'io/wait'
100
101
  end
101
102
  begin # Initialization
102
103
  # Theming
@@ -105,6 +106,7 @@ begin # Initialization
105
106
  @c_nick = 51 # Color for matching nick
106
107
  @c_gnick = 87 # Color for matching gnick
107
108
  @c_path = 208 # Color for valid path
109
+ @c_switch = 148 # Color for switches/options
108
110
  @c_tabselect = 207 # Color for selected tabcompleted item
109
111
  @c_taboption = 244 # Color for unselected tabcompleted item
110
112
  # Prompt
@@ -130,9 +132,9 @@ def getchr # Process key presses
130
132
  c = STDIN.getch
131
133
  case c
132
134
  when "\e" # ANSI escape sequences
133
- case $stdin.getc
135
+ case STDIN.getc
134
136
  when '[' # CSI
135
- case $stdin.getc
137
+ case STDIN.getc
136
138
  when 'A' then chr = "UP"
137
139
  when 'B' then chr = "DOWN"
138
140
  when 'C' then chr = "RIGHT"
@@ -146,7 +148,7 @@ def getchr # Process key presses
146
148
  when '8' then chr = "END" ; chr = "C-END" if STDIN.getc == "^"
147
149
  end
148
150
  when 'O' # Set Ctrl+ArrowKey equal to ArrowKey; May be used for other purposes in the future
149
- case $stdin.getc
151
+ case STDIN.getc
150
152
  when 'a' then chr = "C-UP"
151
153
  when 'b' then chr = "C-DOWN"
152
154
  when 'c' then chr = "C-RIGHT"
@@ -265,6 +267,11 @@ def getstr # A custom Readline-like function
265
267
  @history_copy[@stk].insert(@pos,chr)
266
268
  @pos += 1
267
269
  end
270
+ while STDIN.ready?
271
+ chr = STDIN.getc
272
+ @history_copy[@stk].insert(@pos,chr)
273
+ @pos += 1
274
+ end
268
275
  end
269
276
  @history.insert(0, @history_copy[@stk])
270
277
  @history[0]
@@ -361,6 +368,8 @@ def cmd_check(str) # Check if each element on the readline matches commands, nic
361
368
  el.c(@c_path)
362
369
  elsif system "which #{el}", %i[out err] => File::NULL
363
370
  el.c(@c_cmd)
371
+ elsif el =~ /^-/
372
+ el.c(@c_switch)
364
373
  else
365
374
  el
366
375
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-23 00:00:00.000000000 Z
11
+ date: 2023-05-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
14
- history, syntax highlighting and theming. New in 0.2: Speed-up of syntax highlighting'
14
+ history, syntax highlighting and theming. New in 0.3: You can now paste onto the
15
+ command line.'
15
16
  email: g@isene.com
16
17
  executables:
17
18
  - rsh