rtfm-filemanager 2.8 → 3.0.1

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 +172 -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: a3c73523541e14a20a1fbbb8077fecbc0fdcc2bdfb6e8085aa706dcac26c3bf0
4
+ data.tar.gz: c89d725dcaa8ee7bca932d2e1103d8a6eb122b1b696516572087a655e168f284
5
5
  SHA512:
6
- metadata.gz: 0ea3ca000322dedb9b3dc6779dac28384fbd3fcc05430f3c1f02ffeed76bb3717ae3c484164a922f3d44048cdb4f898cb6829a96e077b371c780ed5c5bbcd3b6
7
- data.tar.gz: 687de104bc2e71a1f6de6896908ed5c23bb5ef9e67cafa2240a2047e36e90f13c68c07f9a02e0dc15e9bae07b8d4d422800b1711b9d93302d4d52068d1258dd1
6
+ metadata.gz: b5e3f9207e0e54164a6af79c6b482a9d8c140591777803b8967bddee282efa89efa071872dfd582548ea15f1b5025d1dbd18a3185b2af0be7bb5a80b7ab22920
7
+ data.tar.gz: 057e62da825a792ef55131873e9b74c9319f47d5ee8b0b1579fb83c5442312c94d737009d56468fae4e722fe3a2c30b72bf30f19a8b8514f297d3d05120ac1b7
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
@@ -14,6 +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 = "3.0.1"
17
18
 
18
19
  # PRELIMINARIES
19
20
  @help = <<HELPTEXT
@@ -27,6 +28,7 @@ BASIC KEYS
27
28
  (@lsall, @lslong, @lsorder, @lsinvert, @border, @width, @preview, @tagged, @marks)
28
29
  q = Quit
29
30
  Q = QUIT (without writing changes to the config file)
31
+ v = Display RTFM version in bottom window/command bar
30
32
 
31
33
  MOTION
32
34
  j/DOWN = Go one item down in left pane (rounds to top)
@@ -47,12 +49,15 @@ JUMPING AND MARKS
47
49
  M = Show marked items in right pane
48
50
  ' = Jump to mark (next letter is the name of the mark [a-zA-Z'])
49
51
  The 5 latest directories visited are stored in marks 1-5 (1 being the very latest)
52
+ ~ = Jump to Home directory
53
+ > = Follow symlink to the directory where the target resides
54
+
55
+ SEARCHING
50
56
  / = Enter search string in bottom window to highlight matching items and jump to the first match
51
- \ = Remove search pattern
57
+ \\ = Remove search pattern
52
58
  n = Jump to the next item matched by '/'
53
59
  N = Jump to the previous item matched by '/'
54
- ~ = Jump to Home directory
55
- > = Follow symlink to the directory where the target resides
60
+ g = Run 'grep' to show files that contains the MATCH in current directory
56
61
  L = Start 'locate' search for files, then use '#' to jump to desired line/directory
57
62
  Ctrl-l = Locate files via fzf from the current directory down
58
63
  (fuzzy file finder must be installed https://github.com/junegunn/fzf)
@@ -69,6 +74,9 @@ MANIPULATE ITEMS
69
74
  s = Create symlink to tagged items here
70
75
  d = Delete selected item and tagged items. Press 'y' to confirm
71
76
  c = Change/rename selected (adds command to bottom window)
77
+ Ctrl-o = Change ownership to user:group of selected and tagged items
78
+ Ctrl-p = Change permissions of selected and tagged items
79
+ Format = rwxr-xr-x or 755 or rwx (applies the trio to user, group and others)
72
80
  z = Extract tagged zipped archive to current directory
73
81
  Z = Create zipped archive from tagged files/directories
74
82
 
@@ -89,7 +97,7 @@ RIGHT PANE
89
97
  ENTER = Refresh the right pane
90
98
  TAB = Next page of the preview (if doc long and ∇ in the bottom right)
91
99
  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 ⇒ ¼ ⅕ ⇒ ⅙ ⇒ ½ ⇒ ⅓)
100
+ w = Change the width of the left/right panes (left pane ⇒ 20%, 30%, 40%, 50%, 60%)
93
101
  - = (Minus sign) Toggle preview in right pane (turn it off for faster traversing of directories)
94
102
  _ = (Underscore) Toggle preview of images in right pane
95
103
  b = Toggle syntax highlighting (and line numbering)
@@ -97,7 +105,6 @@ RIGHT PANE
97
105
  ADDITIONAL COMMANDS
98
106
  f = Show only files in the left pane matching extension(s) (e.g. "txt" or "pdf,png,jpg")
99
107
  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
108
  B = Toggle border
102
109
  : = Enter "command mode" in bottom window (press ENTER to execute, press Ctrl-G to escape)
103
110
  ; = Show command history in right pane
@@ -176,7 +183,7 @@ begin # BASIC SETUP
176
183
  @lsorder = "" # Change the order/sorting by pressing 'o' (circular toggle)
177
184
  @lsinvert = "" # Set to "-r" to reverse/invert sorting order
178
185
  @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
186
+ @width = 4 # Set width of the left pane to the default ⅓ of the terminal width
180
187
  @history = [] # Initialize the command line history array
181
188
  @border = false
182
189
  @preview = true
@@ -313,6 +320,8 @@ def getchr # PROCESS KEY PRESSES
313
320
  when "" then chr = "C-G"
314
321
  when " " then chr = "C-L"
315
322
  when "" then chr = "C-N"
323
+ when "" then chr = "C-O"
324
+ when "" then chr = "C-P"
316
325
  when "" then chr = "C-T"
317
326
  when "" then chr = "C-Y"
318
327
  when "\r" then chr = "ENTER"
@@ -350,6 +359,8 @@ def main_getkey # GET KEY FROM USER
350
359
  system("printf \"\033]0;#{Dir.pwd}\007\"")
351
360
  @write_conf = false
352
361
  exit 0
362
+ when 'v'
363
+ w_b_info("RTFM version = #{@version} (latest RubyGems version is #{Gem.latest_version_for("rtfm-filemanager").version} - https://github.com/isene/RTFM)")
353
364
  # MOTION
354
365
  when 'DOWN', 'j', 'C-DOWN'
355
366
  var_resets
@@ -457,6 +468,37 @@ def main_getkey # GET KEY FROM USER
457
468
  end
458
469
  end
459
470
  @w_b.update = true
471
+ # SEARCHING
472
+ when '/' # Get search string to mark items that match the input
473
+ @w_b.nohistory = true
474
+ @searched = w_b_getstr("/ ", "")
475
+ l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
476
+ m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
477
+ @index = m[0] unless m == []
478
+ @index = 0 if @searched == ""
479
+ @w_r.update = true
480
+ when '\\' # Clear search string
481
+ @searched = ""
482
+ when 'n' # Jump to next occurence of search (after '/')
483
+ l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
484
+ m = l.each_index.select{|n| l[n] =~ /#{@searched}/}
485
+ i = m.find { |n| n > @index }
486
+ if i == nil
487
+ @index = m.first
488
+ else
489
+ @index = i
490
+ end
491
+ @w_r.update = true
492
+ when 'N' # Jump to previous occurence of search (after '/')
493
+ l = `ls 2>/dev/null #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}`.split
494
+ m = l.each_index.select{|n| l[n] =~ /#{@searched}/}.reverse
495
+ i = m.find { |n| n < @index }
496
+ if i == nil
497
+ @index = m.first
498
+ else
499
+ @index = i
500
+ end
501
+ @w_r.update = true
460
502
  when 'g' # Run 'grep' in the current directory
461
503
  cmd = w_b_getstr(": ", "grep -s MATCH *")
462
504
  w_b_exec(cmd)
@@ -480,6 +522,18 @@ def main_getkey # GET KEY FROM USER
480
522
  @w_r.pager = 0
481
523
  end
482
524
  @w_b.update = true
525
+ when 'C-L' # fzf integration (https://github.com/junegunn/fzf)
526
+ begin
527
+ jump = `fzf`.chomp
528
+ rescue
529
+ w_b_info(" fzf not installed - see https://github.com/junegunn/fzf")
530
+ end
531
+ jumpdir = File.dirname(jump)
532
+ @searched = File.basename(jump)
533
+ @directory[Dir.pwd] = @selected # Store this directory before leaving
534
+ mark_latest
535
+ Dir.chdir(jumpdir)
536
+ @break = true
483
537
  # TAGGING
484
538
  when 't' # Add item to tagged list
485
539
  item = "\"#{Dir.pwd}/#{@selected}\""
@@ -551,6 +605,55 @@ def main_getkey # GET KEY FROM USER
551
605
  w_b_info(err.to_s)
552
606
  end
553
607
  @w_r.update = true
608
+ when 'C-O' # Change ownerships
609
+ require 'etc'
610
+ gnm = Etc.getgrgid(File.stat(@selected).gid).name
611
+ unm = Etc.getpwuid(File.stat(@selected).uid).name
612
+ p = "Change ownership of selected"
613
+ p += " and tagged" unless @tagged.empty?
614
+ p += ". Selected ownership (user:group) = "
615
+ own = w_b_getstr(p, "#{unm}:#{gnm}").split(":")
616
+ gnm, unm = own[0], own[1]
617
+ begin
618
+ gid = Etc.getgrnam(gnm).gid.to_i
619
+ uid = Etc.getpwnam(unm).uid.to_i
620
+ File.chown(uid, gid, @selected)
621
+ @tagged.each {|t| File.chown(uid, gid, t[1...-1])} unless @tagged.empty?
622
+ w_b_info("Ownership changed to #{gnm}:#{unm}")
623
+ rescue StandardError => err
624
+ w_b_info(err.to_s)
625
+ end
626
+ when 'C-P' # Change permissions
627
+ mode = @fspes[@index][1..9]
628
+ p = "Change permissions of selected"
629
+ p += " and tagged" unless @tagged.empty?
630
+ p += ". Selected permissions = "
631
+ mode = w_b_getstr(p, mode)
632
+ mode = mode * 3 if mode.length == 3 and mode.to_i == 0
633
+ if mode.length == 9 and mode.to_i == 0
634
+ x = 0
635
+ x += 400 if mode[0] == "r"
636
+ x += 200 if mode[1] == "w"
637
+ x += 100 if mode[2] == "x"
638
+ x += 40 if mode[3] == "r"
639
+ x += 20 if mode[4] == "w"
640
+ x += 10 if mode[5] == "x"
641
+ x += 4 if mode[6] == "r"
642
+ x += 2 if mode[7] == "w"
643
+ x += 1 if mode[8] == "x"
644
+ mode = x
645
+ end
646
+ if mode.to_s.length == 3 and mode.to_i != 0
647
+ mode = mode.to_s.to_i(8)
648
+ begin
649
+ File.chmod(mode, @selected)
650
+ @tagged.each {|t| File.chmod(mode, t[1...-1])} unless @tagged.empty?
651
+ rescue StandardError => err
652
+ w_b_info(err.to_s)
653
+ end
654
+ else
655
+ w_b_info("Not a valid permissions mode. Nothing changed.")
656
+ end
554
657
  when 'z' # Unzip selected archive file
555
658
  cmd = w_b_getstr("Command = ", "tar xfz #{@tagged.first}")
556
659
  begin
@@ -638,45 +741,6 @@ def main_getkey # GET KEY FROM USER
638
741
  end
639
742
  @w_r.update = true
640
743
  @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
744
  when 'I' # OpenAI integration
681
745
  if @ai
682
746
  openai
@@ -708,10 +772,8 @@ def main_getkey # GET KEY FROM USER
708
772
  @width += 1
709
773
  @width = 2 if @width == 7
710
774
  @break = true
775
+ @w_r.update = true
711
776
  @w_b.update = true
712
- when 'B' # Toggle borders
713
- @border = !@border
714
- @break = true
715
777
  when '-' # Toggle content view in right pane
716
778
  @preview = !@preview
717
779
  @preview ? p = "On" : p = "Off"
@@ -724,7 +786,7 @@ def main_getkey # GET KEY FROM USER
724
786
  w_b_info("Image preview = " + i)
725
787
  getch
726
788
  @break = true
727
- when 'b'
789
+ when 'b' # Toggle syntax highlighting (via bat/batcat)
728
790
  @batuse = !@batuse
729
791
  @break = true
730
792
  # ADDITIONAL COMMANDS
@@ -737,55 +799,9 @@ def main_getkey # GET KEY FROM USER
737
799
  when 'F' # Filter out files not matching @lsmatch
738
800
  @lsmatch = w_b_getstr("Files will match RegEx: ", @lsmatch)
739
801
  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
802
+ when 'B' # Toggle borders
803
+ @border = !@border
758
804
  @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
805
  when ':' # Enter "command mode" in the bottom window - tries to execute the given command
790
806
  @w_r.nohistory = false
791
807
  cmd = w_b_getstr(": ", "")
@@ -820,8 +836,17 @@ def main_getkey # GET KEY FROM USER
820
836
  @cont = @cont [1...-1]
821
837
  w_b_info(" Right pane copied to clipboard")
822
838
  system("echo -n '#{@cont}' | #{clip}")
839
+ when 'S' # Show comprehensive system info
840
+ sysinfo
841
+ when 'C-N' # navi integration (https://github.com/denisidoro/navi)
842
+ begin
843
+ @navi = `navi`
844
+ rescue
845
+ w_b_info(" navi not installed - see https://github.com/denisidoro/navi")
846
+ end
847
+ @break = true
823
848
  when '@' # Enter "Ruby debug"
824
- @w_b.nohistory = true
849
+ @w_b.nohistory = false
825
850
  cmd = w_b_getstr("◆ ", "")
826
851
  @w_b.clr
827
852
  @w_b.refresh
@@ -903,7 +928,7 @@ def get_files(win) # The core of the directory listings
903
928
  ls_cmd += @selected_safe if win == "right"
904
929
  @files = `#{ls_cmd}`.split("\n")
905
930
  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"}']
931
+ ls_cmd += %q[ -lh --time-style="long-iso" | awk '{printf "%s%s%s%11s%6s%6s", $1, " " $3, ":" $4,$6,$7,$5"\n"}']
907
932
  @fspes = `#{ls_cmd}`.split("\n").drop(1)
908
933
  if @lsfiles != "" or @lsmatch != ""
909
934
  lsf = @lsfiles.split(",").map! {|e| e.strip}
@@ -1183,9 +1208,9 @@ def w_r_doc # GET FULL CONTENT TO PAGE
1183
1208
  end
1184
1209
  def w_r_info(info) # SHOW INFO IN THE RIGHT WINDOW
1185
1210
  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
1211
+ @w_r.clr
1212
+ @w_r.refresh
1213
+ w_r_width = Curses.cols - (Curses.cols * @width / 10) - 2
1189
1214
  info.gsub!(/(.{1,#{w_r_width}})( +|$\n?)|(.{1,#{w_r_width}})/, "\\1\\3\n")
1190
1215
  @w_r.text = info
1191
1216
  @w_r.pager_cmd = ""
@@ -1220,9 +1245,9 @@ def image_show(image)# SHOW THE SELECTED IMAGE IN THE RIGHT WINDOW
1220
1245
  term_h = terminfo.match(/Height: (\d+)/)[1].to_i
1221
1246
  char_w = term_w / Curses.cols
1222
1247
  char_h = term_h / Curses.lines
1223
- img_x = char_w * (Curses.cols/@width + 1)
1248
+ img_x = char_w * (Curses.cols * @width / 10 + 1)
1224
1249
  img_y = char_h * 2
1225
- img_max_w = char_w * (Curses.cols - Curses.cols/@width - 2)
1250
+ img_max_w = char_w * (Curses.cols - Curses.cols * @width / 10 - 2)
1226
1251
  img_max_h = char_h * (Curses.lines - 4)
1227
1252
  if image == "clear"
1228
1253
  `clear`
@@ -1324,6 +1349,46 @@ def openai # INTERFACE TO OPENAI
1324
1349
  @w_r.fg = 229
1325
1350
  w_r_info(text)
1326
1351
  end
1352
+ def sysinfo
1353
+ begin
1354
+ @w_r.clr
1355
+ @w_r.pager_cmd = ""
1356
+ uname = `uname -o`.chomp + " "
1357
+ uname += `uname -r`.chomp + " "
1358
+ uname += `uname -v`.chomp + " "
1359
+ uname += `uname -p`.chomp + " "
1360
+ uname += `awk -F '"' '/PRETTY/ {print $2}' /etc/os-release` + "\n"
1361
+ text = [[253, 1, uname]]
1362
+ system = "Shell & Terminal: " + `echo $SHELL`.sub(/.*\//, '').chomp + ", " + `echo $TERM`.chomp + " "
1363
+ packages = `pacman -Q 2>/dev/null | wc -l`.chomp
1364
+ packages = `dpkg-query -l 2>/dev/null | grep -c '^.i'`.chomp if packages == "0"
1365
+ packages = "Unrecognized" if packages == "0"
1366
+ system += "Packages: " + packages + "\n"
1367
+ system += "Desktop: " + `awk '/^DesktopNames/' /usr/share/xsessions/* | sed 's/DesktopNames=//g' | \\
1368
+ sed 's/\\;/\\n/g' | sed '/^$/d' | sort -u | sed ':a;N;$!ba;s/\\n/, /g'`.chomp + "/"
1369
+ system += `grep 'gtk-theme-name' ~/.config/gtk-3.0/* | sed 's/gtk-theme-name=//g' | \\
1370
+ sed 's/-/ /g'`.sub(/.*:/, '') + "\n"
1371
+ text += [[251, 0, system]]
1372
+ cpu = "CPUs = " + `nproc`.chop + " "
1373
+ cpuinfo = `lscpu`
1374
+ cpu += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
1375
+ cpu += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
1376
+ cpu += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz\n\n"
1377
+ text += [[154, 0, cpu]]
1378
+ mem = `free -h` + "\n"
1379
+ text += [[229, 0, mem]]
1380
+ ps = `ps -eo comm,pid,user,pcpu,pmem,stat --sort -pcpu,-pmem | head` + "\n"
1381
+ text += [[195, 0, ps]]
1382
+ disk = `df -H | head -8`
1383
+ text += [[172, 0, disk]]
1384
+ dmesg = "\nDMESG (latest first):\n"
1385
+ dmesg += `dmesg | tail -6`.split("\n").sort.reverse.join("\n")
1386
+ text += [[219, 0, dmesg]]
1387
+ w_r_info(ansifix(text))
1388
+ rescue
1389
+ w_r_info("Unable to show system info")
1390
+ end
1391
+ end
1327
1392
  # BOTTOM WINDOW FUNCTIONS
1328
1393
  def w_b_info(info) # SHOW INFO IN @W_B
1329
1394
  @w_b.clr
@@ -1521,9 +1586,9 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
1521
1586
  # Curses::Window.new(h,w,y,x)
1522
1587
  @w_t = Curses::Window.new(1, 0, 0, 0)
1523
1588
  @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)
1589
+ @w_l = Curses::Window.new(maxy - 3, (maxx * @width / 10) - 1, 2, 0)
1590
+ @w_r = Curses::Window.new(maxy - 4, maxx - (maxx * @width / 10), 2, maxx * @width / 10)
1591
+ @w_p = Curses::Window.new(1, maxx - (maxx * @width / 10), maxy - 2, maxx * @width / 10)
1527
1592
  @w_p.fg, @w_p.bg = 255, 0
1528
1593
  @w_p.refresh
1529
1594
  @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.1
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. 3.0.1: Added version info (key ''v'')'
51
52
  email: g@isene.com
52
53
  executables:
53
54
  - rtfm