rtfm-filemanager 2.7 → 3.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.
- checksums.yaml +4 -4
- data/README.md +17 -10
- data/bin/rtfm +176 -112
- 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: a7cea9d99cea882fb8663b99cdb2689a95a2376308c39c6d62c005b6a6240e52
|
|
4
|
+
data.tar.gz: 8570c3db9008c37525e859f62e98a272b406888dd5293a69b4458176ea6630a0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4dd36ec43b4cdca08be792f1d21b0993dea346cba4b3b75517fd42841babc3df45365a55daadf09056711da959c032d83b143c3c307f0cc6bce99e09b931c6f1
|
|
7
|
+
data.tar.gz: 88d4ed18d8cb7e55ad69e63017c15c594721db2fdc1e0d0e4c12ca7ad56da047a848004ef91482d3da7827e1b51563cdbc9bce670befeaf249a1585fe80161fd
|
data/README.md
CHANGED
|
@@ -179,12 +179,18 @@ Key | Description
|
|
|
179
179
|
m | Mark current dir (persistent). Next letter is the name of the mark [a-zA-Z'] The special mark "'" jumps to the last directory (makes toggling dirs easy) Press '-' and a letter to delete that mark
|
|
180
180
|
M | Show marked items in right pane
|
|
181
181
|
' | Jump to mark (next letter is the name of the mark [a-zA-Z']). The 5 latest directories visited are stored in marks 1-5 (1 being the very latest)
|
|
182
|
+
~ | Jump to Home directory
|
|
183
|
+
\> | Follow symlink to the directory where the target resides
|
|
184
|
+
|
|
185
|
+
### Searching
|
|
186
|
+
|
|
187
|
+
Key | Description
|
|
188
|
+
-------|------------------------------------------------------------------
|
|
182
189
|
/ | Enter search string in bottom window to highlight matching items and jump to the first match
|
|
183
190
|
\\ | Remove search pattern
|
|
184
191
|
n | Jump to the next item matched by '/'
|
|
185
192
|
N | Jump to the previous item matched by '/'
|
|
186
|
-
|
|
187
|
-
\> | Follow symlink to the directory where the target resides
|
|
193
|
+
g | Run 'grep' to show files that contains the MATCH in current directory
|
|
188
194
|
L | Start 'locate' search for files, then use '#' to jump to desired line/directory
|
|
189
195
|
Ctrl-l | Locate files via fzf from the current directory down (fuzzy file finder must be installed https://github.com/junegunn/fzf)
|
|
190
196
|
|
|
@@ -206,6 +212,8 @@ P | PUT (move) tagged items here
|
|
|
206
212
|
s | Create symlink to tagged items here
|
|
207
213
|
d | Delete selected item and tagged items. Press 'y' to confirm
|
|
208
214
|
c | Change/rename selected (adds command to bottom window)
|
|
215
|
+
Ctrl-o | Change ownership to user:group of selected and tagged items
|
|
216
|
+
Ctrl-p | Change permissions of selected and tagged items. Format = rwxr-xr-x or 755 or rwx (applies the trio to user, group and others)
|
|
209
217
|
z | Extract tagged zipped archive to current directory
|
|
210
218
|
Z | Create zipped archive from tagged files/directories
|
|
211
219
|
|
|
@@ -240,7 +248,6 @@ Key | Description
|
|
|
240
248
|
-------|------------------------------------------------------------------
|
|
241
249
|
f | Show only files in the left pane matching extension(s) (e.g. "txt" or "pdf,png,jpg")
|
|
242
250
|
F | Show only files matching a pattern (Ruby Regex) (e.g. "abc" or "ab.+12(\w3)*")
|
|
243
|
-
g | Run 'grep' to show files that contains the MATCH in current directory
|
|
244
251
|
B | Toggle border
|
|
245
252
|
: | Enter "command mode" in bottom window (press ENTER to execute, press Ctrl-G to escape)
|
|
246
253
|
; | Show command history in right pane
|
|
@@ -312,15 +319,15 @@ that session.
|
|
|
312
319
|
The top line shows information about the currently item in the left pane. When
|
|
313
320
|
you are at a file, the information is pretty self explanatory:
|
|
314
321
|
|
|
315
|
-
`Path: /home/geir/RTFM/README.md (-rw-
|
|
322
|
+
`Path: /home/geir/RTFM/README.md (-rw-r--r-- geir:geir 2023-04-25 11:49 16K)`
|
|
316
323
|
|
|
317
|
-
This shows the full path of the selected file as well as the permissions
|
|
318
|
-
the size of the file. When you are at a directory in
|
|
319
|
-
two numbers in brackets. The first number is the number
|
|
320
|
-
in that directory. The second shows the total number of
|
|
321
|
-
hidden directories and files:
|
|
324
|
+
This shows the full path of the selected file as well as the permissions,
|
|
325
|
+
ownership, timestamp and the size of the file. When you are at a directory in
|
|
326
|
+
the left pane, you get two numbers in brackets. The first number is the number
|
|
327
|
+
of regular dirs/files in that directory. The second shows the total number of
|
|
328
|
+
entries, including the hidden directories and files:
|
|
322
329
|
|
|
323
|
-
`Path: /home/geir/RTFM (
|
|
330
|
+
`Path: /home/geir/RTFM (drwxr-xr-x geir:geir 2023-04-29 01:55 4,0) [4 8]`
|
|
324
331
|
|
|
325
332
|
Different file types may have extra self explanatory information included in
|
|
326
333
|
square brackets at the end of the top info line. Image files will have the
|
data/bin/rtfm
CHANGED
|
@@ -47,12 +47,15 @@ JUMPING AND MARKS
|
|
|
47
47
|
M = Show marked items in right pane
|
|
48
48
|
' = Jump to mark (next letter is the name of the mark [a-zA-Z'])
|
|
49
49
|
The 5 latest directories visited are stored in marks 1-5 (1 being the very latest)
|
|
50
|
+
~ = Jump to Home directory
|
|
51
|
+
> = Follow symlink to the directory where the target resides
|
|
52
|
+
|
|
53
|
+
SEARCHING
|
|
50
54
|
/ = Enter search string in bottom window to highlight matching items and jump to the first match
|
|
51
|
-
|
|
55
|
+
\\ = Remove search pattern
|
|
52
56
|
n = Jump to the next item matched by '/'
|
|
53
57
|
N = Jump to the previous item matched by '/'
|
|
54
|
-
|
|
55
|
-
> = Follow symlink to the directory where the target resides
|
|
58
|
+
g = Run 'grep' to show files that contains the MATCH in current directory
|
|
56
59
|
L = Start 'locate' search for files, then use '#' to jump to desired line/directory
|
|
57
60
|
Ctrl-l = Locate files via fzf from the current directory down
|
|
58
61
|
(fuzzy file finder must be installed https://github.com/junegunn/fzf)
|
|
@@ -69,6 +72,9 @@ MANIPULATE ITEMS
|
|
|
69
72
|
s = Create symlink to tagged items here
|
|
70
73
|
d = Delete selected item and tagged items. Press 'y' to confirm
|
|
71
74
|
c = Change/rename selected (adds command to bottom window)
|
|
75
|
+
Ctrl-o = Change ownership to user:group of selected and tagged items
|
|
76
|
+
Ctrl-p = Change permissions of selected and tagged items
|
|
77
|
+
Format = rwxr-xr-x or 755 or rwx (applies the trio to user, group and others)
|
|
72
78
|
z = Extract tagged zipped archive to current directory
|
|
73
79
|
Z = Create zipped archive from tagged files/directories
|
|
74
80
|
|
|
@@ -89,7 +95,7 @@ RIGHT PANE
|
|
|
89
95
|
ENTER = Refresh the right pane
|
|
90
96
|
TAB = Next page of the preview (if doc long and ∇ in the bottom right)
|
|
91
97
|
S-TAB = Previous page (if you have moved down the document first - ∆ in the top right)
|
|
92
|
-
w = Change the width of the left/right panes (left pane ⇒
|
|
98
|
+
w = Change the width of the left/right panes (left pane ⇒ 20%, 30%, 40%, 50%, 60%)
|
|
93
99
|
- = (Minus sign) Toggle preview in right pane (turn it off for faster traversing of directories)
|
|
94
100
|
_ = (Underscore) Toggle preview of images in right pane
|
|
95
101
|
b = Toggle syntax highlighting (and line numbering)
|
|
@@ -97,7 +103,6 @@ RIGHT PANE
|
|
|
97
103
|
ADDITIONAL COMMANDS
|
|
98
104
|
f = Show only files in the left pane matching extension(s) (e.g. "txt" or "pdf,png,jpg")
|
|
99
105
|
F = Show only files matching a pattern (Ruby Regex) (e.g. "abc" or "ab.+12(\w3)*")
|
|
100
|
-
g = Run 'grep' to show files that contains the MATCH in current directory
|
|
101
106
|
B = Toggle border
|
|
102
107
|
: = Enter "command mode" in bottom window (press ENTER to execute, press Ctrl-G to escape)
|
|
103
108
|
; = Show command history in right pane
|
|
@@ -156,7 +161,6 @@ begin # BASIC SETUP
|
|
|
156
161
|
@showimage = false unless (cmd?('xwininfo') and cmd?('xdotool'))
|
|
157
162
|
|
|
158
163
|
cmd?('bat') ? @bat = "bat" : @bat = "batcat"
|
|
159
|
-
@batuse = true
|
|
160
164
|
|
|
161
165
|
STDIN.set_encoding(Encoding::UTF_8) # Set encoding for STDIN
|
|
162
166
|
LScolors = `echo $LS_COLORS` # Import LS_COLORS
|
|
@@ -177,11 +181,12 @@ begin # BASIC SETUP
|
|
|
177
181
|
@lsorder = "" # Change the order/sorting by pressing 'o' (circular toggle)
|
|
178
182
|
@lsinvert = "" # Set to "-r" to reverse/invert sorting order
|
|
179
183
|
@lsuser = "" # Set this variable in .rtfm.conf to any 'ls' switch you want to customize directory listings
|
|
180
|
-
@width =
|
|
184
|
+
@width = 4 # Set width of the left pane to the default ⅓ of the terminal width
|
|
181
185
|
@history = [] # Initialize the command line history array
|
|
182
186
|
@border = false
|
|
183
187
|
@preview = true
|
|
184
188
|
@runmailcap = false # Set to 'true' in .rtfm.conf if you want to use run-mailcap instead of xdg-open
|
|
189
|
+
@batuse = true # Use batcat for syntax highlighting
|
|
185
190
|
## These are automatically written on exit
|
|
186
191
|
@marks = {} # Initialize (book)marks hash
|
|
187
192
|
@hash = {} # Initialize the sha directory hashing
|
|
@@ -193,6 +198,7 @@ begin # BASIC SETUP
|
|
|
193
198
|
@lsmatch = "" # Files to match (initially set to matching all files) - not saved on exit
|
|
194
199
|
@index = 0 # Set chosen item to first on startup
|
|
195
200
|
@cont = ""
|
|
201
|
+
@tagsize = 0
|
|
196
202
|
@navi = ""
|
|
197
203
|
@marks["'"] = Dir.pwd
|
|
198
204
|
## File type recognizers
|
|
@@ -312,6 +318,8 @@ def getchr # PROCESS KEY PRESSES
|
|
|
312
318
|
when "" then chr = "C-G"
|
|
313
319
|
when "" then chr = "C-L"
|
|
314
320
|
when "" then chr = "C-N"
|
|
321
|
+
when "" then chr = "C-O"
|
|
322
|
+
when "" then chr = "C-P"
|
|
315
323
|
when "" then chr = "C-T"
|
|
316
324
|
when "" then chr = "C-Y"
|
|
317
325
|
when "\r" then chr = "ENTER"
|
|
@@ -456,6 +464,37 @@ def main_getkey # GET KEY FROM USER
|
|
|
456
464
|
end
|
|
457
465
|
end
|
|
458
466
|
@w_b.update = true
|
|
467
|
+
# SEARCHING
|
|
468
|
+
when '/' # Get search string to mark items that match the input
|
|
469
|
+
@w_b.nohistory = true
|
|
470
|
+
@searched = w_b_getstr("/ ", "")
|
|
471
|
+
l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
|
|
472
|
+
m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
|
|
473
|
+
@index = m[0] unless m == []
|
|
474
|
+
@index = 0 if @searched == ""
|
|
475
|
+
@w_r.update = true
|
|
476
|
+
when '\\' # Clear search string
|
|
477
|
+
@searched = ""
|
|
478
|
+
when 'n' # Jump to next occurence of search (after '/')
|
|
479
|
+
l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
|
|
480
|
+
m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
|
|
481
|
+
i = m.find { |n| n > @index }
|
|
482
|
+
if i == nil
|
|
483
|
+
@index = m.first
|
|
484
|
+
else
|
|
485
|
+
@index = i
|
|
486
|
+
end
|
|
487
|
+
@w_r.update = true
|
|
488
|
+
when 'N' # Jump to previous occurence of search (after '/')
|
|
489
|
+
l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
|
|
490
|
+
m = l.each_index.select{|n| l[n] =~ /#{@searched}/}.reverse
|
|
491
|
+
i = m.find { |n| n < @index }
|
|
492
|
+
if i == nil
|
|
493
|
+
@index = m.first
|
|
494
|
+
else
|
|
495
|
+
@index = i
|
|
496
|
+
end
|
|
497
|
+
@w_r.update = true
|
|
459
498
|
when 'g' # Run 'grep' in the current directory
|
|
460
499
|
cmd = w_b_getstr(": ", "grep -s MATCH *")
|
|
461
500
|
w_b_exec(cmd)
|
|
@@ -479,13 +518,27 @@ def main_getkey # GET KEY FROM USER
|
|
|
479
518
|
@w_r.pager = 0
|
|
480
519
|
end
|
|
481
520
|
@w_b.update = true
|
|
521
|
+
when 'C-L' # fzf integration (https://github.com/junegunn/fzf)
|
|
522
|
+
begin
|
|
523
|
+
jump = `fzf`.chomp
|
|
524
|
+
rescue
|
|
525
|
+
w_b_info(" fzf not installed - see https://github.com/junegunn/fzf")
|
|
526
|
+
end
|
|
527
|
+
jumpdir = File.dirname(jump)
|
|
528
|
+
@searched = File.basename(jump)
|
|
529
|
+
@directory[Dir.pwd] = @selected # Store this directory before leaving
|
|
530
|
+
mark_latest
|
|
531
|
+
Dir.chdir(jumpdir)
|
|
532
|
+
@break = true
|
|
482
533
|
# TAGGING
|
|
483
534
|
when 't' # Add item to tagged list
|
|
484
535
|
item = "\"#{Dir.pwd}/#{@selected}\""
|
|
485
536
|
if @tagged.include?(item)
|
|
486
537
|
@tagged.delete(item)
|
|
538
|
+
@tagsize -= File.size(item[1...-1])
|
|
487
539
|
else
|
|
488
540
|
@tagged.push(item)
|
|
541
|
+
@tagsize += File.size(item[1...-1])
|
|
489
542
|
end
|
|
490
543
|
@index += 1
|
|
491
544
|
@w_r.update = true
|
|
@@ -548,6 +601,55 @@ def main_getkey # GET KEY FROM USER
|
|
|
548
601
|
w_b_info(err.to_s)
|
|
549
602
|
end
|
|
550
603
|
@w_r.update = true
|
|
604
|
+
when 'C-O' # Change ownerships
|
|
605
|
+
require 'etc'
|
|
606
|
+
gnm = Etc.getgrgid(File.stat(@selected).gid).name
|
|
607
|
+
unm = Etc.getpwuid(File.stat(@selected).uid).name
|
|
608
|
+
p = "Change ownership of selected"
|
|
609
|
+
p += " and tagged" unless @tagged.empty?
|
|
610
|
+
p += ". Selected ownership (user:group) = "
|
|
611
|
+
own = w_b_getstr(p, "#{unm}:#{gnm}").split(":")
|
|
612
|
+
gnm, unm = own[0], own[1]
|
|
613
|
+
begin
|
|
614
|
+
gid = Etc.getgrnam(gnm).gid.to_i
|
|
615
|
+
uid = Etc.getpwnam(unm).uid.to_i
|
|
616
|
+
File.chown(uid, gid, @selected)
|
|
617
|
+
@tagged.each {|t| File.chown(uid, gid, t[1...-1])} unless @tagged.empty?
|
|
618
|
+
w_b_info("Ownership changed to #{gnm}:#{unm}")
|
|
619
|
+
rescue StandardError => err
|
|
620
|
+
w_b_info(err.to_s)
|
|
621
|
+
end
|
|
622
|
+
when 'C-P' # Change permissions
|
|
623
|
+
mode = @fspes[@index][1..9]
|
|
624
|
+
p = "Change permissions of selected"
|
|
625
|
+
p += " and tagged" unless @tagged.empty?
|
|
626
|
+
p += ". Selected permissions = "
|
|
627
|
+
mode = w_b_getstr(p, mode)
|
|
628
|
+
mode = mode * 3 if mode.length == 3 and mode.to_i == 0
|
|
629
|
+
if mode.length == 9 and mode.to_i == 0
|
|
630
|
+
x = 0
|
|
631
|
+
x += 400 if mode[0] == "r"
|
|
632
|
+
x += 200 if mode[1] == "w"
|
|
633
|
+
x += 100 if mode[2] == "x"
|
|
634
|
+
x += 40 if mode[3] == "r"
|
|
635
|
+
x += 20 if mode[4] == "w"
|
|
636
|
+
x += 10 if mode[5] == "x"
|
|
637
|
+
x += 4 if mode[6] == "r"
|
|
638
|
+
x += 2 if mode[7] == "w"
|
|
639
|
+
x += 1 if mode[8] == "x"
|
|
640
|
+
mode = x
|
|
641
|
+
end
|
|
642
|
+
if mode.to_s.length == 3 and mode.to_i != 0
|
|
643
|
+
mode = mode.to_s.to_i(8)
|
|
644
|
+
begin
|
|
645
|
+
File.chmod(mode, @selected)
|
|
646
|
+
@tagged.each {|t| File.chmod(mode, t[1...-1])} unless @tagged.empty?
|
|
647
|
+
rescue StandardError => err
|
|
648
|
+
w_b_info(err.to_s)
|
|
649
|
+
end
|
|
650
|
+
else
|
|
651
|
+
w_b_info("Not a valid permissions mode. Nothing changed.")
|
|
652
|
+
end
|
|
551
653
|
when 'z' # Unzip selected archive file
|
|
552
654
|
cmd = w_b_getstr("Command = ", "tar xfz #{@tagged.first}")
|
|
553
655
|
begin
|
|
@@ -635,45 +737,6 @@ def main_getkey # GET KEY FROM USER
|
|
|
635
737
|
end
|
|
636
738
|
@w_r.update = true
|
|
637
739
|
@w_b.update = false
|
|
638
|
-
when 'S' # Show comprehensive system info
|
|
639
|
-
begin
|
|
640
|
-
@w_r.clr
|
|
641
|
-
@w_r.pager_cmd = ""
|
|
642
|
-
uname = `uname -o`.chomp + " "
|
|
643
|
-
uname += `uname -r`.chomp + " "
|
|
644
|
-
uname += `uname -v`.chomp + " "
|
|
645
|
-
uname += `uname -p`.chomp + " "
|
|
646
|
-
uname += `awk -F '"' '/PRETTY/ {print $2}' /etc/os-release` + "\n"
|
|
647
|
-
text = [[253, 1, uname]]
|
|
648
|
-
system = "Shell & Terminal: " + `echo $SHELL`.sub(/.*\//, '').chomp + ", " + `echo $TERM`.chomp + " "
|
|
649
|
-
packages = `pacman -Q 2>/dev/null | wc -l`.chomp
|
|
650
|
-
packages = `dpkg-query -l 2>/dev/null | grep -c '^.i'`.chomp if packages == "0"
|
|
651
|
-
packages = "Unrecognized" if packages == "0"
|
|
652
|
-
system += "Packages: " + packages + "\n"
|
|
653
|
-
system += "Desktop: " + `awk '/^DesktopNames/' /usr/share/xsessions/* | sed 's/DesktopNames=//g' | \\
|
|
654
|
-
sed 's/\\;/\\n/g' | sed '/^$/d' | sort -u | sed ':a;N;$!ba;s/\\n/, /g'`.chomp + "/"
|
|
655
|
-
system += `grep 'gtk-theme-name' ~/.config/gtk-3.0/* | sed 's/gtk-theme-name=//g' | \\
|
|
656
|
-
sed 's/-/ /g'`.sub(/.*:/, '') + "\n"
|
|
657
|
-
text += [[251, 0, system]]
|
|
658
|
-
cpu = "CPUs = " + `nproc`.chop + " "
|
|
659
|
-
cpuinfo = `lscpu`
|
|
660
|
-
cpu += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
|
|
661
|
-
cpu += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
|
|
662
|
-
cpu += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz\n\n"
|
|
663
|
-
text += [[154, 0, cpu]]
|
|
664
|
-
mem = `free -h` + "\n"
|
|
665
|
-
text += [[229, 0, mem]]
|
|
666
|
-
ps = `ps -eo comm,pid,user,pcpu,pmem,stat --sort -pcpu,-pmem | head` + "\n"
|
|
667
|
-
text += [[195, 0, ps]]
|
|
668
|
-
disk = `df -H | head -8`
|
|
669
|
-
text += [[172, 0, disk]]
|
|
670
|
-
dmesg = "\nDMESG (latest first):\n"
|
|
671
|
-
dmesg += `dmesg | tail -6`.split("\n").sort.reverse.join("\n")
|
|
672
|
-
text += [[219, 0, dmesg]]
|
|
673
|
-
w_r_info(ansifix(text))
|
|
674
|
-
rescue
|
|
675
|
-
w_r_info("Unable to show system info")
|
|
676
|
-
end
|
|
677
740
|
when 'I' # OpenAI integration
|
|
678
741
|
if @ai
|
|
679
742
|
openai
|
|
@@ -705,10 +768,8 @@ def main_getkey # GET KEY FROM USER
|
|
|
705
768
|
@width += 1
|
|
706
769
|
@width = 2 if @width == 7
|
|
707
770
|
@break = true
|
|
771
|
+
@w_r.update = true
|
|
708
772
|
@w_b.update = true
|
|
709
|
-
when 'B' # Toggle borders
|
|
710
|
-
@border = !@border
|
|
711
|
-
@break = true
|
|
712
773
|
when '-' # Toggle content view in right pane
|
|
713
774
|
@preview = !@preview
|
|
714
775
|
@preview ? p = "On" : p = "Off"
|
|
@@ -721,7 +782,7 @@ def main_getkey # GET KEY FROM USER
|
|
|
721
782
|
w_b_info("Image preview = " + i)
|
|
722
783
|
getch
|
|
723
784
|
@break = true
|
|
724
|
-
when 'b'
|
|
785
|
+
when 'b' # Toggle syntax highlighting (via bat/batcat)
|
|
725
786
|
@batuse = !@batuse
|
|
726
787
|
@break = true
|
|
727
788
|
# ADDITIONAL COMMANDS
|
|
@@ -734,55 +795,9 @@ def main_getkey # GET KEY FROM USER
|
|
|
734
795
|
when 'F' # Filter out files not matching @lsmatch
|
|
735
796
|
@lsmatch = w_b_getstr("Files will match RegEx: ", @lsmatch)
|
|
736
797
|
w_b_info(nil)
|
|
737
|
-
when '
|
|
738
|
-
|
|
739
|
-
jump = `fzf`.chomp
|
|
740
|
-
rescue
|
|
741
|
-
w_b_info(" fzf not installed - see https://github.com/junegunn/fzf")
|
|
742
|
-
end
|
|
743
|
-
jumpdir = File.dirname(jump)
|
|
744
|
-
@searched = File.basename(jump)
|
|
745
|
-
@directory[Dir.pwd] = @selected # Store this directory before leaving
|
|
746
|
-
mark_latest
|
|
747
|
-
Dir.chdir(jumpdir)
|
|
748
|
-
@break = true
|
|
749
|
-
when 'C-N' # navi integration (https://github.com/denisidoro/navi)
|
|
750
|
-
begin
|
|
751
|
-
@navi = `navi`
|
|
752
|
-
rescue
|
|
753
|
-
w_b_info(" navi not installed - see https://github.com/denisidoro/navi")
|
|
754
|
-
end
|
|
798
|
+
when 'B' # Toggle borders
|
|
799
|
+
@border = !@border
|
|
755
800
|
@break = true
|
|
756
|
-
when '/' # Get search string to mark items that match the input
|
|
757
|
-
@w_b.nohistory = true
|
|
758
|
-
@searched = w_b_getstr("/ ", "")
|
|
759
|
-
l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
|
|
760
|
-
m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
|
|
761
|
-
@index = m[0] unless m == []
|
|
762
|
-
@index = 0 if @searched == ""
|
|
763
|
-
@w_r.update = true
|
|
764
|
-
when '\\'
|
|
765
|
-
@searched = ""
|
|
766
|
-
when 'n' # Jump to next occurence of search (after '/')
|
|
767
|
-
l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
|
|
768
|
-
m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
|
|
769
|
-
i = m.find { |n| n > @index }
|
|
770
|
-
if i == nil
|
|
771
|
-
@index = m.first
|
|
772
|
-
else
|
|
773
|
-
@index = i
|
|
774
|
-
end
|
|
775
|
-
@w_r.update = true
|
|
776
|
-
when 'N' # Jump to previous occurence of search (after '/')
|
|
777
|
-
l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
|
|
778
|
-
m = l.each_index.select{|n| l[n] =~ /#{@searched}/}.reverse
|
|
779
|
-
i = m.find { |n| n < @index }
|
|
780
|
-
if i == nil
|
|
781
|
-
@index = m.first
|
|
782
|
-
else
|
|
783
|
-
@index = i
|
|
784
|
-
end
|
|
785
|
-
@w_r.update = true
|
|
786
801
|
when ':' # Enter "command mode" in the bottom window - tries to execute the given command
|
|
787
802
|
@w_r.nohistory = false
|
|
788
803
|
cmd = w_b_getstr(": ", "")
|
|
@@ -817,8 +832,17 @@ def main_getkey # GET KEY FROM USER
|
|
|
817
832
|
@cont = @cont [1...-1]
|
|
818
833
|
w_b_info(" Right pane copied to clipboard")
|
|
819
834
|
system("echo -n '#{@cont}' | #{clip}")
|
|
835
|
+
when 'S' # Show comprehensive system info
|
|
836
|
+
sysinfo
|
|
837
|
+
when 'C-N' # navi integration (https://github.com/denisidoro/navi)
|
|
838
|
+
begin
|
|
839
|
+
@navi = `navi`
|
|
840
|
+
rescue
|
|
841
|
+
w_b_info(" navi not installed - see https://github.com/denisidoro/navi")
|
|
842
|
+
end
|
|
843
|
+
@break = true
|
|
820
844
|
when '@' # Enter "Ruby debug"
|
|
821
|
-
@w_b.nohistory =
|
|
845
|
+
@w_b.nohistory = false
|
|
822
846
|
cmd = w_b_getstr("◆ ", "")
|
|
823
847
|
@w_b.clr
|
|
824
848
|
@w_b.refresh
|
|
@@ -900,7 +924,7 @@ def get_files(win) # The core of the directory listings
|
|
|
900
924
|
ls_cmd += @selected_safe if win == "right"
|
|
901
925
|
@files = `#{ls_cmd}`.split("\n")
|
|
902
926
|
ls_cmd += " -H " if win == "right"
|
|
903
|
-
ls_cmd += %q[ -
|
|
927
|
+
ls_cmd += %q[ -lh --time-style="long-iso" | awk '{printf "%s%s%s%11s%6s%6s", $1, " " $3, ":" $4,$6,$7,$5"\n"}']
|
|
904
928
|
@fspes = `#{ls_cmd}`.split("\n").drop(1)
|
|
905
929
|
if @lsfiles != "" or @lsmatch != ""
|
|
906
930
|
lsf = @lsfiles.split(",").map! {|e| e.strip}
|
|
@@ -1180,9 +1204,9 @@ def w_r_doc # GET FULL CONTENT TO PAGE
|
|
|
1180
1204
|
end
|
|
1181
1205
|
def w_r_info(info) # SHOW INFO IN THE RIGHT WINDOW
|
|
1182
1206
|
image_show("clear") if @image; @image = false
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
w_r_width = Curses.cols - (Curses.cols
|
|
1207
|
+
@w_r.clr
|
|
1208
|
+
@w_r.refresh
|
|
1209
|
+
w_r_width = Curses.cols - (Curses.cols * @width / 10) - 2
|
|
1186
1210
|
info.gsub!(/(.{1,#{w_r_width}})( +|$\n?)|(.{1,#{w_r_width}})/, "\\1\\3\n")
|
|
1187
1211
|
@w_r.text = info
|
|
1188
1212
|
@w_r.pager_cmd = ""
|
|
@@ -1217,9 +1241,9 @@ def image_show(image)# SHOW THE SELECTED IMAGE IN THE RIGHT WINDOW
|
|
|
1217
1241
|
term_h = terminfo.match(/Height: (\d+)/)[1].to_i
|
|
1218
1242
|
char_w = term_w / Curses.cols
|
|
1219
1243
|
char_h = term_h / Curses.lines
|
|
1220
|
-
img_x = char_w * (Curses.cols
|
|
1244
|
+
img_x = char_w * (Curses.cols * @width / 10 + 1)
|
|
1221
1245
|
img_y = char_h * 2
|
|
1222
|
-
img_max_w = char_w * (Curses.cols - Curses.cols
|
|
1246
|
+
img_max_w = char_w * (Curses.cols - Curses.cols * @width / 10 - 2)
|
|
1223
1247
|
img_max_h = char_h * (Curses.lines - 4)
|
|
1224
1248
|
if image == "clear"
|
|
1225
1249
|
`clear`
|
|
@@ -1321,17 +1345,57 @@ def openai # INTERFACE TO OPENAI
|
|
|
1321
1345
|
@w_r.fg = 229
|
|
1322
1346
|
w_r_info(text)
|
|
1323
1347
|
end
|
|
1324
|
-
|
|
1348
|
+
def sysinfo
|
|
1349
|
+
begin
|
|
1350
|
+
@w_r.clr
|
|
1351
|
+
@w_r.pager_cmd = ""
|
|
1352
|
+
uname = `uname -o`.chomp + " "
|
|
1353
|
+
uname += `uname -r`.chomp + " "
|
|
1354
|
+
uname += `uname -v`.chomp + " "
|
|
1355
|
+
uname += `uname -p`.chomp + " "
|
|
1356
|
+
uname += `awk -F '"' '/PRETTY/ {print $2}' /etc/os-release` + "\n"
|
|
1357
|
+
text = [[253, 1, uname]]
|
|
1358
|
+
system = "Shell & Terminal: " + `echo $SHELL`.sub(/.*\//, '').chomp + ", " + `echo $TERM`.chomp + " "
|
|
1359
|
+
packages = `pacman -Q 2>/dev/null | wc -l`.chomp
|
|
1360
|
+
packages = `dpkg-query -l 2>/dev/null | grep -c '^.i'`.chomp if packages == "0"
|
|
1361
|
+
packages = "Unrecognized" if packages == "0"
|
|
1362
|
+
system += "Packages: " + packages + "\n"
|
|
1363
|
+
system += "Desktop: " + `awk '/^DesktopNames/' /usr/share/xsessions/* | sed 's/DesktopNames=//g' | \\
|
|
1364
|
+
sed 's/\\;/\\n/g' | sed '/^$/d' | sort -u | sed ':a;N;$!ba;s/\\n/, /g'`.chomp + "/"
|
|
1365
|
+
system += `grep 'gtk-theme-name' ~/.config/gtk-3.0/* | sed 's/gtk-theme-name=//g' | \\
|
|
1366
|
+
sed 's/-/ /g'`.sub(/.*:/, '') + "\n"
|
|
1367
|
+
text += [[251, 0, system]]
|
|
1368
|
+
cpu = "CPUs = " + `nproc`.chop + " "
|
|
1369
|
+
cpuinfo = `lscpu`
|
|
1370
|
+
cpu += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
|
|
1371
|
+
cpu += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
|
|
1372
|
+
cpu += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz\n\n"
|
|
1373
|
+
text += [[154, 0, cpu]]
|
|
1374
|
+
mem = `free -h` + "\n"
|
|
1375
|
+
text += [[229, 0, mem]]
|
|
1376
|
+
ps = `ps -eo comm,pid,user,pcpu,pmem,stat --sort -pcpu,-pmem | head` + "\n"
|
|
1377
|
+
text += [[195, 0, ps]]
|
|
1378
|
+
disk = `df -H | head -8`
|
|
1379
|
+
text += [[172, 0, disk]]
|
|
1380
|
+
dmesg = "\nDMESG (latest first):\n"
|
|
1381
|
+
dmesg += `dmesg | tail -6`.split("\n").sort.reverse.join("\n")
|
|
1382
|
+
text += [[219, 0, dmesg]]
|
|
1383
|
+
w_r_info(ansifix(text))
|
|
1384
|
+
rescue
|
|
1385
|
+
w_r_info("Unable to show system info")
|
|
1386
|
+
end
|
|
1387
|
+
end
|
|
1325
1388
|
# BOTTOM WINDOW FUNCTIONS
|
|
1326
1389
|
def w_b_info(info) # SHOW INFO IN @W_B
|
|
1327
1390
|
@w_b.clr
|
|
1328
1391
|
@w_b.fg, @w_b.bg = 250, 238
|
|
1329
1392
|
if info == nil
|
|
1330
1393
|
info = ": for command (use @s for selected item, @t for tagged items) - press ? for help"
|
|
1331
|
-
info = "Showing only files matching '#{@lsmatch}'" if @lsmatch != ""
|
|
1332
|
-
info = "Showing only file type '#{@lsfiles}'" if @lsfiles != ""
|
|
1333
|
-
info = "Showing only file types '#{@lsfiles}'" if @lsfiles =~ /,/
|
|
1394
|
+
info = " Showing only files matching '#{@lsmatch}'" if @lsmatch != ""
|
|
1395
|
+
info = " Showing only file type '#{@lsfiles}'" if @lsfiles != ""
|
|
1396
|
+
info = " Showing only file types '#{@lsfiles}'" if @lsfiles =~ /,/
|
|
1334
1397
|
info += " and only files matching '#{@lsmatch}'" if @lsfiles != "" and @lsmatch != ""
|
|
1398
|
+
info = " Tagged #{@tagged.size} files (#{(@tagsize.to_f/1000000).round(2)}MB)" unless @tagged.empty?
|
|
1335
1399
|
@w_b.fg, @w_b.bg = 250, 88 if @lsfiles != ""
|
|
1336
1400
|
@w_b.fg, @w_b.bg = 250, 21 if @lsmatch != ""
|
|
1337
1401
|
@w_b.fg, @w_b.bg = 250, 55 if @lsfiles != "" and @lsmatch != ""
|
|
@@ -1518,9 +1582,9 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
|
|
|
1518
1582
|
# Curses::Window.new(h,w,y,x)
|
|
1519
1583
|
@w_t = Curses::Window.new(1, 0, 0, 0)
|
|
1520
1584
|
@w_b = Curses::Window.new(1, 0, maxy - 1, 0)
|
|
1521
|
-
@w_l = Curses::Window.new(maxy - 3, (maxx
|
|
1522
|
-
@w_r = Curses::Window.new(maxy - 4, maxx - (maxx
|
|
1523
|
-
@w_p = Curses::Window.new(1, maxx - (maxx
|
|
1585
|
+
@w_l = Curses::Window.new(maxy - 3, (maxx * @width / 10) - 1, 2, 0)
|
|
1586
|
+
@w_r = Curses::Window.new(maxy - 4, maxx - (maxx * @width / 10), 2, maxx * @width / 10)
|
|
1587
|
+
@w_p = Curses::Window.new(1, maxx - (maxx * @width / 10), maxy - 2, maxx * @width / 10)
|
|
1524
1588
|
@w_p.fg, @w_p.bg = 255, 0
|
|
1525
1589
|
@w_p.refresh
|
|
1526
1590
|
@w_t.fg, @w_t.bg = 232, 249
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rtfm-filemanager
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '
|
|
4
|
+
version: '3.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: 2023-04-
|
|
11
|
+
date: 2023-04-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: curses
|
|
@@ -47,8 +47,8 @@ dependencies:
|
|
|
47
47
|
description: 'A full featured terminal browser with syntax highlighted files, images
|
|
48
48
|
shown in the terminal, videos thumbnailed, etc. You can bookmark and jump around
|
|
49
49
|
easily, delete, rename, copy, symlink and move files. RTFM has a a wide range of
|
|
50
|
-
other features. New in
|
|
51
|
-
|
|
50
|
+
other features. New in 3.0: Added ownership (Ctrl-O) and permissions (Ctrl-P) handling.
|
|
51
|
+
Better width stepping. Code refactoring.'
|
|
52
52
|
email: g@isene.com
|
|
53
53
|
executables:
|
|
54
54
|
- rtfm
|