ruby-shell 0.1 → 0.3
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.
- checksums.yaml +4 -4
- data/README.md +11 -5
- data/bin/rsh +14 -5
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: beb9449aa1999b4050dc9fc33e6bd34cfd72e53298f9a30260cdd7326c0c11f3
|
4
|
+
data.tar.gz: dbcf1ce70ae0a19d50a09fa5c28a43b83e6cfc67df6ebe67073994daa2721d8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c11546df1ddae55bea7cceab32b3084398a5b87bd32c4fa815e41ec8f236bdcb197af2c03e66fffe5dd7d9365d1936409066301d4d7941d5022f95c5f6b555c
|
7
|
+
data.tar.gz: 77838d06aebc6b9c92009f789cfe45666febce20aa5aaf7b90bbbb1c15c38a9acfba32c3a98e6c0bdf9218350987bd1cbd3f09787013fd40fc9e7f810f8afda0
|
data/README.md
CHANGED
@@ -10,7 +10,7 @@ Simple. One file. Minimum external requirements.
|
|
10
10
|
# Installation
|
11
11
|
Clone this repo and drop `rsh` into your preferred bin directory. Drop `.rshrc` into your home directory and edit as you see fit.
|
12
12
|
|
13
|
-
Or simply `gem install
|
13
|
+
Or simply `gem install ruby-shell`.
|
14
14
|
|
15
15
|
# Features
|
16
16
|
* Aliases (called `nicks`in rsh) - both for commands and general nicks
|
@@ -21,13 +21,13 @@ Or simply `gem install rsh`.
|
|
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
|
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 `:
|
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
|
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
|
-
#
|
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.
|
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
|
135
|
+
case STDIN.getc
|
134
136
|
when '[' # CSI
|
135
|
-
case
|
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
|
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]
|
@@ -359,8 +366,10 @@ def cmd_check(str) # Check if each element on the readline matches commands, nic
|
|
359
366
|
el.c(@c_gnick)
|
360
367
|
elsif File.exists?(el.sub(/^~/, "/home/#{@user}"))
|
361
368
|
el.c(@c_path)
|
362
|
-
elsif system
|
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.
|
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-
|
11
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: A shell written in Ruby with extensive tab completions, aliases/nicks,
|
14
|
-
history, syntax highlighting and theming.
|
13
|
+
description: 'A shell written in Ruby with extensive tab completions, aliases/nicks,
|
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
|