ruby-shell 1.0.1 → 1.2
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 +2 -1
- data/bin/rsh +43 -33
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d3646331db7eac6ea26f07f0878354ca9b3ed9f46ebda4e2bd177d252ce67d3
|
|
4
|
+
data.tar.gz: deffdb053c7284ed35110c482a30adfd0ec732ce5eb0d2ea4188638cf92d1b0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6dec4e805bf977dd4de28784a1e1bc4c71c7df0c865c73e479e54d053de0743b9592c4c1d331e321da23d1c1e4136709fd7fb269acb372dac50d4aa3f1196737
|
|
7
|
+
data.tar.gz: d50d00d2f0f9af08c1516941a808087936d512f43971eb2374b476c295137048c95bb0890960589dfdc35b9b402147d0c9d162ee1b1d75b0e6ae8b2bc541c7ed
|
data/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
The Ruby SHell
|
|
5
5
|
|
|
6
6
|
# Why?
|
|
7
|
-
Ruby is my goto language (pun kinda intended). I want full control over my tools and I like challenges that I can tinker with late at night. This is an incomplete project continually being improved. Feel free to add suggestions or code.
|
|
7
|
+
<img src="img/rsh-logo.jpg" align="left" width="150" height="150">Ruby is my goto language (pun kinda intended). I want full control over my tools and I like challenges that I can tinker with late at night. This is an incomplete project continually being improved. Feel free to add suggestions or code.
|
|
8
8
|
|
|
9
9
|
# Design principles
|
|
10
10
|
Simple. One file. Minimum external requirements.
|
|
@@ -29,6 +29,7 @@ Or simply `gem install ruby-shell`.
|
|
|
29
29
|
* Set of simple rsh specific commands like nick, nick?, history and rmhistory
|
|
30
30
|
* rsh specific commands and full set of Ruby commands available via :<command>
|
|
31
31
|
* All colors are themeable in .rshrc (see github link for possibilities)
|
|
32
|
+
* Copy current command line to primary selection (paste w/middle button) with `Ctrl-y`
|
|
32
33
|
|
|
33
34
|
Special functions/integrations:
|
|
34
35
|
* Use `r` to launch rtfm (https://github.com/isene/RTFM) - if you have it installed
|
data/bin/rsh
CHANGED
|
@@ -7,25 +7,20 @@
|
|
|
7
7
|
# Author: Geir Isene <g@isene.com>
|
|
8
8
|
# Web_site: http://isene.com/
|
|
9
9
|
# Github: https://github.com/isene/rsh
|
|
10
|
-
# License:
|
|
11
|
-
|
|
12
|
-
# this software for any purpose. I make no guarantee about the
|
|
13
|
-
# suitability of this software for any purpose and I am not liable
|
|
14
|
-
# for any damages resulting from its use. Further, I am under no
|
|
15
|
-
# obligation to maintain or extend this software. It is provided
|
|
16
|
-
# on an 'as is' basis without any expressed or implied warranty.
|
|
17
|
-
@version = "1.0.1"
|
|
10
|
+
# License: Public domain
|
|
11
|
+
@version = "1.2"
|
|
18
12
|
|
|
19
13
|
# MODULES, CLASSES AND EXTENSIONS
|
|
20
14
|
class String # Add coloring to strings (with escaping for Readline)
|
|
21
|
-
def c(code); color(self, "\001\e[38;5;#{code}m\002"); end
|
|
22
|
-
def b; color(self, "\001\e[1m\002"); end
|
|
23
|
-
def i; color(self, "\001\e[3m\002"); end
|
|
24
|
-
def u; color(self, "\001\e[4m\002"); end
|
|
25
|
-
def l; color(self, "\001\e[5m\002"); end
|
|
15
|
+
def c(code); color(self, "\001\e[38;5;#{code}m\002"); end # Color code
|
|
16
|
+
def b; color(self, "\001\e[1m\002"); end # Bold
|
|
17
|
+
def i; color(self, "\001\e[3m\002"); end # Italic
|
|
18
|
+
def u; color(self, "\001\e[4m\002"); end # Underline
|
|
19
|
+
def l; color(self, "\001\e[5m\002"); end # Blink
|
|
20
|
+
def r; color(self, "\001\e[7m\002"); end # Reverse
|
|
26
21
|
def color(text, color_code) "#{color_code}#{text}\001\e[0m\002" end
|
|
27
22
|
end
|
|
28
|
-
module Cursor # Terminal cursor movement ANSI codes (thanks to https://github.com/piotrmurach/tty-cursor
|
|
23
|
+
module Cursor # Terminal cursor movement ANSI codes (thanks to https://github.com/piotrmurach/tty-cursor)
|
|
29
24
|
module_function
|
|
30
25
|
ESC = "\e".freeze
|
|
31
26
|
CSI = "\e[".freeze
|
|
@@ -102,13 +97,13 @@ begin # Requires
|
|
|
102
97
|
end
|
|
103
98
|
begin # Initialization
|
|
104
99
|
# Theming
|
|
105
|
-
@c_prompt =
|
|
106
|
-
@c_cmd =
|
|
107
|
-
@c_nick =
|
|
108
|
-
@c_gnick =
|
|
109
|
-
@c_path =
|
|
110
|
-
@c_switch =
|
|
111
|
-
@c_tabselect =
|
|
100
|
+
@c_prompt = 10 # Color for basic prompt
|
|
101
|
+
@c_cmd = 2 # Color for valid command
|
|
102
|
+
@c_nick = 6 # Color for matching nick
|
|
103
|
+
@c_gnick = 14 # Color for matching gnick
|
|
104
|
+
@c_path = 3 # Color for valid path
|
|
105
|
+
@c_switch = 6 # Color for switches/options
|
|
106
|
+
@c_tabselect = 5 # Color for selected tabcompleted item
|
|
112
107
|
@c_taboption = 244 # Color for unselected tabcompleted item
|
|
113
108
|
@c_stamp = 244 # Color for time stamp/command
|
|
114
109
|
# Prompt
|
|
@@ -123,12 +118,14 @@ begin # Initialization
|
|
|
123
118
|
"/usr/bin",
|
|
124
119
|
"/home/#{@user}/bin"] # Basic paths for executables if not set in .rshrc
|
|
125
120
|
# History
|
|
126
|
-
@histsize =
|
|
121
|
+
@histsize = 200 # Max history if not set in .rshrc
|
|
127
122
|
@hloaded = false # Variable to determine if history is loaded
|
|
128
|
-
# Use run-mailcap instead of xgd-open? Set = true in .rshrc if
|
|
123
|
+
# Use run-mailcap instead of xgd-open? Set "= true" in .rshrc if you want run-mailcap
|
|
129
124
|
@runmailcap = false
|
|
130
125
|
# Variable initializations
|
|
131
126
|
@dirs = ["."]*10
|
|
127
|
+
def pre_cmd; end # User-defined function to be run BEFORE command execution
|
|
128
|
+
def post_cmd; end # User-defined function to be run AFTER command execution
|
|
132
129
|
end
|
|
133
130
|
|
|
134
131
|
# HELP TEXT
|
|
@@ -153,12 +150,14 @@ end
|
|
|
153
150
|
* Set of simple rsh specific commands like nick, nick?, history and rmhistory
|
|
154
151
|
* rsh specific commands and full set of Ruby commands available via :<command>
|
|
155
152
|
* All colors are themeable in .rshrc (see github link for possibilities)
|
|
156
|
-
|
|
153
|
+
* Copy current command line to primary selection (paste w/middle button) with `Ctrl-y`
|
|
154
|
+
|
|
157
155
|
Special functions/integrations:
|
|
158
156
|
* Use `r` to launch rtfm (https://github.com/isene/RTFM) - if you have it installed
|
|
159
157
|
* Use `f` to launch fzf (https://github.com/junegunn/fzf) - if you have it installed
|
|
160
|
-
* Use `=` followed by xrpn commands separated by commas (https://github.com/isene/xrpn)
|
|
158
|
+
* Use `=` followed by xrpn commands separated by commas or double-spaces (https://github.com/isene/xrpn)
|
|
161
159
|
* Use `:` followed by a Ruby expression to access the whole world of Ruby
|
|
160
|
+
|
|
162
161
|
Special commands:
|
|
163
162
|
* `:nick 'll = ls -l'` to make a command alias (ll) point to a command (ls -l)
|
|
164
163
|
* `:gnick 'h = /home/me'` to make a general alias (h) point to something (/home/me)
|
|
@@ -217,6 +216,7 @@ def getchr # Process key presses
|
|
|
217
216
|
when '6' then chr = "PgDOWN" ; chr = "C-PgDOWN" if STDIN.getc == "^"
|
|
218
217
|
when '7' then chr = "HOME" ; chr = "C-HOME" if STDIN.getc == "^"
|
|
219
218
|
when '8' then chr = "END" ; chr = "C-END" if STDIN.getc == "^"
|
|
219
|
+
else chr = ""
|
|
220
220
|
end
|
|
221
221
|
when 'O' # Set Ctrl+ArrowKey equal to ArrowKey; May be used for other purposes in the future
|
|
222
222
|
case STDIN.getc
|
|
@@ -224,6 +224,7 @@ def getchr # Process key presses
|
|
|
224
224
|
when 'b' then chr = "C-DOWN"
|
|
225
225
|
when 'c' then chr = "C-RIGHT"
|
|
226
226
|
when 'd' then chr = "C-LEFT"
|
|
227
|
+
else chr = ""
|
|
227
228
|
end
|
|
228
229
|
end
|
|
229
230
|
when "", "" then chr = "BACK"
|
|
@@ -243,6 +244,7 @@ def getchr # Process key presses
|
|
|
243
244
|
when "\r" then chr = "ENTER"
|
|
244
245
|
when "\t" then chr = "TAB"
|
|
245
246
|
when /[[:print:]]/ then chr = c
|
|
247
|
+
else chr = ""
|
|
246
248
|
end
|
|
247
249
|
return chr
|
|
248
250
|
end
|
|
@@ -259,9 +261,9 @@ def getstr # A custom Readline-like function
|
|
|
259
261
|
print @prompt
|
|
260
262
|
row, @pos0 = @c.pos
|
|
261
263
|
print cmd_check(@history[0])
|
|
262
|
-
@ci = @history[1..].find_index {|e| e =~ /^#{Regexp.escape(@history[0])}
|
|
264
|
+
@ci = @history[1..].find_index {|e| e =~ /^#{Regexp.escape(@history[0])}./}
|
|
263
265
|
@ci += 1 unless @ci == nil
|
|
264
|
-
if @history[0].length >
|
|
266
|
+
if @history[0].length > 1 and @ci
|
|
265
267
|
print @history[@ci][@history[0].length..].to_s.c(@c_stamp)
|
|
266
268
|
right = true
|
|
267
269
|
end
|
|
@@ -355,6 +357,9 @@ def getstr # A custom Readline-like function
|
|
|
355
357
|
end
|
|
356
358
|
end
|
|
357
359
|
lift = true
|
|
360
|
+
when 'C-Y' # Copy command line to primary selection
|
|
361
|
+
system("echo -n '#{@history[0]}' | xclip")
|
|
362
|
+
puts "\n#{Time.now.strftime("%H:%M:%S")}: Copied to primary selection (paste with middle buttoni)".c(@c_stamp)
|
|
358
363
|
when 'C-K' # Kill/delete that entry in the history
|
|
359
364
|
@history.delete_at(@stk)
|
|
360
365
|
@stk -= 1
|
|
@@ -497,11 +502,11 @@ def tabselect(ary, hist=false) # Let user select from the incoming array
|
|
|
497
502
|
when 'TAB'
|
|
498
503
|
chr = "ENTER"
|
|
499
504
|
when 'BACK'
|
|
505
|
+
@tabsearch.chop!
|
|
500
506
|
if @tabsearch == ''
|
|
501
507
|
@c.clear_screen_down
|
|
502
508
|
return ""
|
|
503
509
|
end
|
|
504
|
-
@tabsearch.chop!
|
|
505
510
|
hist ? tab_hist(@tabsearch) : tab_all(@tabsearch)
|
|
506
511
|
return @tabsearch
|
|
507
512
|
when /^[[:print:]]$/
|
|
@@ -605,9 +610,9 @@ def gnick(nick_str) # Define a generic/global nick to match not only commands (f
|
|
|
605
610
|
end
|
|
606
611
|
def nick? # Show nicks
|
|
607
612
|
puts " Command nicks:".c(@c_nick)
|
|
608
|
-
@nick.each {|key, value| puts " #{key} = #{value}"}
|
|
613
|
+
@nick.sort.each {|key, value| puts " #{key} = #{value}"}
|
|
609
614
|
puts " General nicks:".c(@c_gnick)
|
|
610
|
-
@gnick.each {|key, value| puts " #{key} = #{value}"}
|
|
615
|
+
@gnick.sort.each {|key, value| puts " #{key} = #{value}"}
|
|
611
616
|
end
|
|
612
617
|
def dirs
|
|
613
618
|
puts "Past direactories:"
|
|
@@ -671,7 +676,10 @@ loop do
|
|
|
671
676
|
system("git status .") if Dir.exist?(".git")
|
|
672
677
|
next
|
|
673
678
|
end
|
|
674
|
-
|
|
679
|
+
if @cmd =~ /^\=/ # Integration with xrpn (https://github.com/isene/xrpn)
|
|
680
|
+
@cmd.gsub!(" ", ",")
|
|
681
|
+
@cmd = "echo \"#{@cmd[1...]},prx,off\" | xrpn"
|
|
682
|
+
end
|
|
675
683
|
if @cmd.match(/^\s*:/) # Ruby commands are prefixed with ":"
|
|
676
684
|
begin
|
|
677
685
|
eval(@cmd[1..-1])
|
|
@@ -684,7 +692,7 @@ loop do
|
|
|
684
692
|
else # Execute command
|
|
685
693
|
ca = @nick.transform_keys {|k| /((^\K\s*\K)|(\|\K\s*\K))\b(?<!-)#{Regexp.escape k}\b/}
|
|
686
694
|
@cmd = @cmd.gsub(Regexp.union(ca.keys), @nick)
|
|
687
|
-
ga = @gnick.transform_keys {|k| /\b#{Regexp.escape k}\b/}
|
|
695
|
+
ga = @gnick.transform_keys {|k| /\b(?<!-)#{Regexp.escape k}\b/}
|
|
688
696
|
@cmd = @cmd.gsub(Regexp.union(ga.keys), @gnick)
|
|
689
697
|
@cmd = "~" if @cmd == "cd"
|
|
690
698
|
@cmd.sub!(/^cd (\S*).*/, '\1')
|
|
@@ -712,7 +720,9 @@ loop do
|
|
|
712
720
|
end
|
|
713
721
|
else
|
|
714
722
|
begin
|
|
715
|
-
|
|
723
|
+
pre_cmd
|
|
724
|
+
puts "Not executed: #{@cmd}" unless system (@cmd) # Try execute the command
|
|
725
|
+
post_cmd
|
|
716
726
|
rescue StandardError => err
|
|
717
727
|
puts "\n#{err}"
|
|
718
728
|
end
|
metadata
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-shell
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: '1.2'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-10-10 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. In
|
|
15
|
-
continual development. New in 1.
|
|
15
|
+
continual development. New in 1.2: Fixed bug on tab handling'
|
|
16
16
|
email: g@isene.com
|
|
17
17
|
executables:
|
|
18
18
|
- rsh
|
|
@@ -27,7 +27,7 @@ licenses:
|
|
|
27
27
|
- Unlicense
|
|
28
28
|
metadata:
|
|
29
29
|
source_code_uri: https://github.com/isene/rsh
|
|
30
|
-
post_install_message:
|
|
30
|
+
post_install_message:
|
|
31
31
|
rdoc_options: []
|
|
32
32
|
require_paths:
|
|
33
33
|
- lib
|
|
@@ -42,8 +42,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
42
42
|
- !ruby/object:Gem::Version
|
|
43
43
|
version: '0'
|
|
44
44
|
requirements: []
|
|
45
|
-
rubygems_version: 3.
|
|
46
|
-
signing_key:
|
|
45
|
+
rubygems_version: 3.4.20
|
|
46
|
+
signing_key:
|
|
47
47
|
specification_version: 4
|
|
48
48
|
summary: rsh - Ruby SHell
|
|
49
49
|
test_files: []
|