ruby-shell 0.19 → 0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rshrc +9 -4
- data/README.md +7 -2
- data/bin/rsh +31 -18
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8d28ba94f7b6a6e05496bccb94efe444ba34871ab036b448fb0d074dcadf59d
|
4
|
+
data.tar.gz: 041e37fe2d4876a59b097d74eddd846be9de62915ee857943c4c86b2e4080a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a681b059f27359fa185cc6f1092ac3bf2b8e9084a79ee5650f154b906b25ec84a20eb4920961576a945787cb6d925c6f16cab915383ea9b07ba3a2ed58bc634d
|
7
|
+
data.tar.gz: 04bde7676375ce81782b2ba15abda281a650de049d79734eb23b0db4b67987f089db1b2fd4bf3be52bc5dc6730f900d95acc2ade046fe70097272cf09730673e
|
data/.rshrc
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# vim: set ft=ruby sw=2 sts=2 et :
|
2
2
|
|
3
|
+
# ENVIRONMENT
|
4
|
+
#@lscolors = "/home/geir/.local/share/lscolors.sh"
|
5
|
+
ENV["EDITOR"] = "vim"
|
6
|
+
ENV["MANPAGER"] = "vim +MANPAGER -"
|
7
|
+
|
3
8
|
# PROMPT
|
4
|
-
# The numbers in parenthesis are 256 color codes (the '.c()' is a String extention
|
5
|
-
# to color text in the terminal. Add '.b' for bold and '.i' for italics.
|
6
9
|
if @user == "root"
|
7
|
-
@prompt = "#{@user}@#{@node}".c(160) + ":".c(255) + " #{Dir.pwd}/".c(196) + " ".c(7)
|
10
|
+
@prompt = "#{@user}@#{@node}".c(160).b + ":".c(255) + " #{Dir.pwd}/".c(196) + " ".c(7)
|
8
11
|
else
|
9
12
|
@prompt = "#{@user}@#{@node}".c(46) + ":".c(255) + " #{Dir.pwd}/".c(196) + " ".c(7)
|
10
13
|
end
|
@@ -20,5 +23,7 @@ end
|
|
20
23
|
@c_taboption = 244 # Color for unselected tabcompleted item
|
21
24
|
@c_stamp = 244 # Color for time stamp/command
|
22
25
|
|
23
|
-
#
|
26
|
+
# NICKS AND HISTORY
|
24
27
|
@nick = {"ls"=>"ls --color -F"}
|
28
|
+
@gnick = {}
|
29
|
+
@history = []
|
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Or simply `gem install ruby-shell`.
|
|
23
23
|
* Tab completions for nicks, system commands, command switches and dirs/files
|
24
24
|
* Tab completion presents matches in a list to pick from
|
25
25
|
* When you start to write a command, rsh will suggest the first match in the history and present that in "toned down" letters - press the arrow right key to accept the suggestion.
|
26
|
+
* Writing a partial command and pressing `UP` will search history for matches. Go down/up in the list and press `TAB` or `ENTER` to accept or `Ctrl-G` to discard
|
26
27
|
* History with editing, search and repeat a history command (with `!`)
|
27
28
|
* Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-c)
|
28
29
|
* Set of simple rsh specific commands like nick, nick?, history and rmhistory
|
@@ -89,10 +90,14 @@ Variable | Description
|
|
89
90
|
## The .rshrc
|
90
91
|
`.rshrc` is the configuration file for rsh and it is located in your home directory. It is created when you first start rsh and you can modify it to suit your needs. A more detailed .rshrc is found in the the [rsh github repo](https://github.com/isene/rsh) - you can drop this into your home dir if you like. Set the basic environment variables like this:
|
91
92
|
```
|
92
|
-
|
93
|
+
ENV["EDITOR"] = "vim"
|
94
|
+
ENV["MANPAGER"] = "vim +MANPAGER -"
|
95
|
+
```
|
96
|
+
Also, a special variable for better LS_COLOR setup:
|
97
|
+
```
|
93
98
|
@lscolors = "/home/geir/.local/share/lscolors.sh"
|
94
99
|
```
|
95
|
-
|
100
|
+
Point `@lscolors` to a file that sets your LS_COLORS variable. Use [my extended LS_COLORS setup](https://github.com/isene/LS_COLORS) to make this really fancy.
|
96
101
|
|
97
102
|
You can add any Ruby code to your .rshrc.
|
98
103
|
|
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.21"
|
18
18
|
|
19
19
|
# MODULES, CLASSES AND EXTENSIONS
|
20
20
|
class String # Add coloring to strings (with escaping for Readline)
|
@@ -145,8 +145,10 @@ end
|
|
145
145
|
* Tab completions for nicks, system commands, command switches and dirs/files
|
146
146
|
* Tab completion presents matches in a list to pick from
|
147
147
|
* When you start to write a command, rsh will suggest the first match in the history and
|
148
|
-
present that in "toned down" letters - press the arrow right key to accept the suggestion
|
149
|
-
*
|
148
|
+
present that in "toned down" letters - press the arrow right key to accept the suggestion
|
149
|
+
* Writing a partial command and pressing `UP` will search history for matches.
|
150
|
+
Go down/up in the list and press `TAB` or `ENTER` to accept or `Ctrl-G` to discard
|
151
|
+
* History with editing, search and repeat a history command (with `!`)
|
150
152
|
* Config file (.rshrc) updates on exit (with Ctrl-d) or not (with Ctrl-c)
|
151
153
|
* Set of simple rsh specific commands like nick, nick?, history and rmhistory
|
152
154
|
* rsh specific commands and full set of Ruby commands available via :<command>
|
@@ -278,17 +280,22 @@ def getstr # A custom Readline-like function
|
|
278
280
|
@c.row(1)
|
279
281
|
@c.clear_screen_down
|
280
282
|
when 'UP' # Go up in history
|
281
|
-
if
|
282
|
-
@history
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
283
|
+
if @stk == 0 and @history[0].length > 0
|
284
|
+
@tabsearch = @history[0]
|
285
|
+
tabbing("hist")
|
286
|
+
else
|
287
|
+
if lift
|
288
|
+
@history.unshift("")
|
289
|
+
@history[0] = @history[@stk].dup
|
290
|
+
@stk += 1
|
291
|
+
end
|
292
|
+
unless @stk >= @history.length - 1
|
293
|
+
@stk += 1
|
294
|
+
@history[0] = @history[@stk].dup
|
295
|
+
@pos = @history[0].length
|
296
|
+
end
|
297
|
+
lift = false
|
290
298
|
end
|
291
|
-
lift = false
|
292
299
|
when 'DOWN' # Go down in history
|
293
300
|
if lift
|
294
301
|
@history.unshift("")
|
@@ -434,8 +441,11 @@ def tab_hist(str)
|
|
434
441
|
sel = @history.select {|el| el =~ /#{str}/}
|
435
442
|
sel.delete("")
|
436
443
|
hist = tabselect(sel, true)
|
437
|
-
|
438
|
-
|
444
|
+
if hist
|
445
|
+
@tabsearch = hist
|
446
|
+
@tabstr = ""
|
447
|
+
@pos = @tabsearch.length
|
448
|
+
end
|
439
449
|
end
|
440
450
|
def tabselect(ary, hist=false) # Let user select from the incoming array
|
441
451
|
ary.uniq!
|
@@ -599,7 +609,10 @@ begin # Load .rshrc and populate @history
|
|
599
609
|
trap "SIGINT" do print "\n"; exit end
|
600
610
|
firstrun unless File.exist?(Dir.home+'/.rshrc') # Initial loading - to get history
|
601
611
|
load(Dir.home+'/.rshrc')
|
602
|
-
ENV["
|
612
|
+
ENV["SHELL"] = __FILE__
|
613
|
+
ENV["TERM"] = "rxvt-unicode-256color"
|
614
|
+
ENV["PATH"] ? ENV["PATH"] += ":" : ENV["PATH"] = ""
|
615
|
+
ENV["PATH"] += "/home/#{@user}/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
603
616
|
if File.exist?(@lscolors)
|
604
617
|
ls = File.read(@lscolors)
|
605
618
|
ls.sub!(/export.*/, '')
|
@@ -676,7 +689,7 @@ loop do
|
|
676
689
|
res = `fzf`.chomp
|
677
690
|
Dir.chdir(File.dirname(res))
|
678
691
|
else
|
679
|
-
if File.exist?(@cmd)
|
692
|
+
if File.exist?(@cmd) and not File.executable?(@cmd)
|
680
693
|
if File.read(@cmd).force_encoding("UTF-8").valid_encoding?
|
681
694
|
system("#{ENV['EDITOR']} #{@cmd}") # Try open with user's editor
|
682
695
|
else
|
@@ -687,7 +700,7 @@ loop do
|
|
687
700
|
end
|
688
701
|
end
|
689
702
|
elsif system(@cmd) # Try execute the command
|
690
|
-
else puts "No such command: #{@cmd}"
|
703
|
+
else puts "No such command or nick: #{@cmd}"
|
691
704
|
end
|
692
705
|
end
|
693
706
|
end
|
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: '0.
|
4
|
+
version: '0.21'
|
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-06-
|
11
|
+
date: 2023-06-15 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 and more. In continual development. New in
|
15
|
-
0.
|
16
|
-
|
15
|
+
0.20: Better history search - write a partial command and press UP to get matches
|
16
|
+
in history.'
|
17
17
|
email: g@isene.com
|
18
18
|
executables:
|
19
19
|
- rsh
|