rtfm-filemanager 2.8 → 3.0

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 +17 -10
  3. data/bin/rtfm +168 -107
  4. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9212de239a0f6cbc4d8962878867141f58a34da9c6083e68d9ea3f004bd3bc1d
4
- data.tar.gz: f2428f14e0f27a4c2469f8723cad43813efdcf0018aad67f6b2006ae6a9ccb80
3
+ metadata.gz: a7cea9d99cea882fb8663b99cdb2689a95a2376308c39c6d62c005b6a6240e52
4
+ data.tar.gz: 8570c3db9008c37525e859f62e98a272b406888dd5293a69b4458176ea6630a0
5
5
  SHA512:
6
- metadata.gz: 0ea3ca000322dedb9b3dc6779dac28384fbd3fcc05430f3c1f02ffeed76bb3717ae3c484164a922f3d44048cdb4f898cb6829a96e077b371c780ed5c5bbcd3b6
7
- data.tar.gz: 687de104bc2e71a1f6de6896908ed5c23bb5ef9e67cafa2240a2047e36e90f13c68c07f9a02e0dc15e9bae07b8d4d422800b1711b9d93302d4d52068d1258dd1
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
- ~ | Jump to Home directory
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-rw-r-- 6,0K)`
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 and
318
- the size of the file. When you are at a directory in the left pane, you get
319
- two numbers in brackets. The first number is the number of regular dirs/files
320
- in that directory. The second shows the total number of entries, including the
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 (drwxrwxr-x 4,0K) [4 8]`
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
- \ = Remove search pattern
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
- ~ = Jump to Home directory
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
@@ -176,7 +181,7 @@ begin # BASIC SETUP
176
181
  @lsorder = "" # Change the order/sorting by pressing 'o' (circular toggle)
177
182
  @lsinvert = "" # Set to "-r" to reverse/invert sorting order
178
183
  @lsuser = "" # Set this variable in .rtfm.conf to any 'ls' switch you want to customize directory listings
179
- @width = 3 # Set width of the left pane to the default ⅓ of the terminal width
184
+ @width = 4 # Set width of the left pane to the default ⅓ of the terminal width
180
185
  @history = [] # Initialize the command line history array
181
186
  @border = false
182
187
  @preview = true
@@ -313,6 +318,8 @@ def getchr # PROCESS KEY PRESSES
313
318
  when "" then chr = "C-G"
314
319
  when " " then chr = "C-L"
315
320
  when "" then chr = "C-N"
321
+ when "" then chr = "C-O"
322
+ when "" then chr = "C-P"
316
323
  when "" then chr = "C-T"
317
324
  when "" then chr = "C-Y"
318
325
  when "\r" then chr = "ENTER"
@@ -457,6 +464,37 @@ def main_getkey # GET KEY FROM USER
457
464
  end
458
465
  end
459
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
460
498
  when 'g' # Run 'grep' in the current directory
461
499
  cmd = w_b_getstr(": ", "grep -s MATCH *")
462
500
  w_b_exec(cmd)
@@ -480,6 +518,18 @@ def main_getkey # GET KEY FROM USER
480
518
  @w_r.pager = 0
481
519
  end
482
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
483
533
  # TAGGING
484
534
  when 't' # Add item to tagged list
485
535
  item = "\"#{Dir.pwd}/#{@selected}\""
@@ -551,6 +601,55 @@ def main_getkey # GET KEY FROM USER
551
601
  w_b_info(err.to_s)
552
602
  end
553
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
554
653
  when 'z' # Unzip selected archive file
555
654
  cmd = w_b_getstr("Command = ", "tar xfz #{@tagged.first}")
556
655
  begin
@@ -638,45 +737,6 @@ def main_getkey # GET KEY FROM USER
638
737
  end
639
738
  @w_r.update = true
640
739
  @w_b.update = false
641
- when 'S' # Show comprehensive system info
642
- begin
643
- @w_r.clr
644
- @w_r.pager_cmd = ""
645
- uname = `uname -o`.chomp + " "
646
- uname += `uname -r`.chomp + " "
647
- uname += `uname -v`.chomp + " "
648
- uname += `uname -p`.chomp + " "
649
- uname += `awk -F '"' '/PRETTY/ {print $2}' /etc/os-release` + "\n"
650
- text = [[253, 1, uname]]
651
- system = "Shell & Terminal: " + `echo $SHELL`.sub(/.*\//, '').chomp + ", " + `echo $TERM`.chomp + " "
652
- packages = `pacman -Q 2>/dev/null | wc -l`.chomp
653
- packages = `dpkg-query -l 2>/dev/null | grep -c '^.i'`.chomp if packages == "0"
654
- packages = "Unrecognized" if packages == "0"
655
- system += "Packages: " + packages + "\n"
656
- system += "Desktop: " + `awk '/^DesktopNames/' /usr/share/xsessions/* | sed 's/DesktopNames=//g' | \\
657
- sed 's/\\;/\\n/g' | sed '/^$/d' | sort -u | sed ':a;N;$!ba;s/\\n/, /g'`.chomp + "/"
658
- system += `grep 'gtk-theme-name' ~/.config/gtk-3.0/* | sed 's/gtk-theme-name=//g' | \\
659
- sed 's/-/ /g'`.sub(/.*:/, '') + "\n"
660
- text += [[251, 0, system]]
661
- cpu = "CPUs = " + `nproc`.chop + " "
662
- cpuinfo = `lscpu`
663
- cpu += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
664
- cpu += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
665
- cpu += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz\n\n"
666
- text += [[154, 0, cpu]]
667
- mem = `free -h` + "\n"
668
- text += [[229, 0, mem]]
669
- ps = `ps -eo comm,pid,user,pcpu,pmem,stat --sort -pcpu,-pmem | head` + "\n"
670
- text += [[195, 0, ps]]
671
- disk = `df -H | head -8`
672
- text += [[172, 0, disk]]
673
- dmesg = "\nDMESG (latest first):\n"
674
- dmesg += `dmesg | tail -6`.split("\n").sort.reverse.join("\n")
675
- text += [[219, 0, dmesg]]
676
- w_r_info(ansifix(text))
677
- rescue
678
- w_r_info("Unable to show system info")
679
- end
680
740
  when 'I' # OpenAI integration
681
741
  if @ai
682
742
  openai
@@ -708,10 +768,8 @@ def main_getkey # GET KEY FROM USER
708
768
  @width += 1
709
769
  @width = 2 if @width == 7
710
770
  @break = true
771
+ @w_r.update = true
711
772
  @w_b.update = true
712
- when 'B' # Toggle borders
713
- @border = !@border
714
- @break = true
715
773
  when '-' # Toggle content view in right pane
716
774
  @preview = !@preview
717
775
  @preview ? p = "On" : p = "Off"
@@ -724,7 +782,7 @@ def main_getkey # GET KEY FROM USER
724
782
  w_b_info("Image preview = " + i)
725
783
  getch
726
784
  @break = true
727
- when 'b'
785
+ when 'b' # Toggle syntax highlighting (via bat/batcat)
728
786
  @batuse = !@batuse
729
787
  @break = true
730
788
  # ADDITIONAL COMMANDS
@@ -737,55 +795,9 @@ def main_getkey # GET KEY FROM USER
737
795
  when 'F' # Filter out files not matching @lsmatch
738
796
  @lsmatch = w_b_getstr("Files will match RegEx: ", @lsmatch)
739
797
  w_b_info(nil)
740
- when 'C-L' # fzf integration (https://github.com/junegunn/fzf)
741
- begin
742
- jump = `fzf`.chomp
743
- rescue
744
- w_b_info(" fzf not installed - see https://github.com/junegunn/fzf")
745
- end
746
- jumpdir = File.dirname(jump)
747
- @searched = File.basename(jump)
748
- @directory[Dir.pwd] = @selected # Store this directory before leaving
749
- mark_latest
750
- Dir.chdir(jumpdir)
751
- @break = true
752
- when 'C-N' # navi integration (https://github.com/denisidoro/navi)
753
- begin
754
- @navi = `navi`
755
- rescue
756
- w_b_info(" navi not installed - see https://github.com/denisidoro/navi")
757
- end
798
+ when 'B' # Toggle borders
799
+ @border = !@border
758
800
  @break = true
759
- when '/' # Get search string to mark items that match the input
760
- @w_b.nohistory = true
761
- @searched = w_b_getstr("/ ", "")
762
- l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
763
- m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
764
- @index = m[0] unless m == []
765
- @index = 0 if @searched == ""
766
- @w_r.update = true
767
- when '\\'
768
- @searched = ""
769
- when 'n' # Jump to next occurence of search (after '/')
770
- l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
771
- m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
772
- i = m.find { |n| n > @index }
773
- if i == nil
774
- @index = m.first
775
- else
776
- @index = i
777
- end
778
- @w_r.update = true
779
- when 'N' # Jump to previous occurence of search (after '/')
780
- l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
781
- m = l.each_index.select{|n| l[n] =~ /#{@searched}/}.reverse
782
- i = m.find { |n| n < @index }
783
- if i == nil
784
- @index = m.first
785
- else
786
- @index = i
787
- end
788
- @w_r.update = true
789
801
  when ':' # Enter "command mode" in the bottom window - tries to execute the given command
790
802
  @w_r.nohistory = false
791
803
  cmd = w_b_getstr(": ", "")
@@ -820,8 +832,17 @@ def main_getkey # GET KEY FROM USER
820
832
  @cont = @cont [1...-1]
821
833
  w_b_info(" Right pane copied to clipboard")
822
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
823
844
  when '@' # Enter "Ruby debug"
824
- @w_b.nohistory = true
845
+ @w_b.nohistory = false
825
846
  cmd = w_b_getstr("◆ ", "")
826
847
  @w_b.clr
827
848
  @w_b.refresh
@@ -903,7 +924,7 @@ def get_files(win) # The core of the directory listings
903
924
  ls_cmd += @selected_safe if win == "right"
904
925
  @files = `#{ls_cmd}`.split("\n")
905
926
  ls_cmd += " -H " if win == "right"
906
- ls_cmd += %q[ -lhgG --time-style="long-iso" | awk '{printf "%s%12s%6s%6s%5s", $1,$4,$5,$3,$2 "\n"}']
927
+ ls_cmd += %q[ -lh --time-style="long-iso" | awk '{printf "%s%s%s%11s%6s%6s", $1, " " $3, ":" $4,$6,$7,$5"\n"}']
907
928
  @fspes = `#{ls_cmd}`.split("\n").drop(1)
908
929
  if @lsfiles != "" or @lsmatch != ""
909
930
  lsf = @lsfiles.split(",").map! {|e| e.strip}
@@ -1183,9 +1204,9 @@ def w_r_doc # GET FULL CONTENT TO PAGE
1183
1204
  end
1184
1205
  def w_r_info(info) # SHOW INFO IN THE RIGHT WINDOW
1185
1206
  image_show("clear") if @image; @image = false
1186
- #@w_r.clr
1187
- #@w_r.refresh
1188
- w_r_width = Curses.cols - (Curses.cols/@width) - 2
1207
+ @w_r.clr
1208
+ @w_r.refresh
1209
+ w_r_width = Curses.cols - (Curses.cols * @width / 10) - 2
1189
1210
  info.gsub!(/(.{1,#{w_r_width}})( +|$\n?)|(.{1,#{w_r_width}})/, "\\1\\3\n")
1190
1211
  @w_r.text = info
1191
1212
  @w_r.pager_cmd = ""
@@ -1220,9 +1241,9 @@ def image_show(image)# SHOW THE SELECTED IMAGE IN THE RIGHT WINDOW
1220
1241
  term_h = terminfo.match(/Height: (\d+)/)[1].to_i
1221
1242
  char_w = term_w / Curses.cols
1222
1243
  char_h = term_h / Curses.lines
1223
- img_x = char_w * (Curses.cols/@width + 1)
1244
+ img_x = char_w * (Curses.cols * @width / 10 + 1)
1224
1245
  img_y = char_h * 2
1225
- img_max_w = char_w * (Curses.cols - Curses.cols/@width - 2)
1246
+ img_max_w = char_w * (Curses.cols - Curses.cols * @width / 10 - 2)
1226
1247
  img_max_h = char_h * (Curses.lines - 4)
1227
1248
  if image == "clear"
1228
1249
  `clear`
@@ -1324,6 +1345,46 @@ def openai # INTERFACE TO OPENAI
1324
1345
  @w_r.fg = 229
1325
1346
  w_r_info(text)
1326
1347
  end
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
1327
1388
  # BOTTOM WINDOW FUNCTIONS
1328
1389
  def w_b_info(info) # SHOW INFO IN @W_B
1329
1390
  @w_b.clr
@@ -1521,9 +1582,9 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
1521
1582
  # Curses::Window.new(h,w,y,x)
1522
1583
  @w_t = Curses::Window.new(1, 0, 0, 0)
1523
1584
  @w_b = Curses::Window.new(1, 0, maxy - 1, 0)
1524
- @w_l = Curses::Window.new(maxy - 3, (maxx/@width) - 1, 2, 0)
1525
- @w_r = Curses::Window.new(maxy - 4, maxx - (maxx/@width), 2, maxx/@width)
1526
- @w_p = Curses::Window.new(1, maxx - (maxx/@width), maxy - 2, maxx/@width)
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)
1527
1588
  @w_p.fg, @w_p.bg = 255, 0
1528
1589
  @w_p.refresh
1529
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: '2.8'
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-25 00:00:00.000000000 Z
11
+ date: 2023-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: curses
@@ -47,7 +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 2.8: Added info about tagged files in bottom status line'
50
+ other features. New in 3.0: Added ownership (Ctrl-O) and permissions (Ctrl-P) handling.
51
+ Better width stepping. Code refactoring.'
51
52
  email: g@isene.com
52
53
  executables:
53
54
  - rtfm