rtfm-filemanager 1.3.3 → 1.3.7
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/bin/rtfm +80 -24
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8f91e8bdcc9ef4971615a32ce6eaafcb76f49bf5025765071b41671fa04dbd
|
4
|
+
data.tar.gz: c94681c000bd0ab6a0ef378a6188bbcdbeaa3e8f2bac98bc83924b8535826a50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7230ecb3e03c0cabedc467dd26d9b641236418fac7b11a847342f2d46931859bdfe198ab03c8f03766499ac2820886cbf4f9477c829fcee10fe6229047b46968
|
7
|
+
data.tar.gz: 8e0da5f055e969a98cdd959ab32bba5ec2d13b021dbe797a196494d9d5e64e8db9b0bd7255bfea9ca9b4db475ba73b375cb91c513dc390149558ac1dbf38af97
|
data/bin/rtfm
CHANGED
@@ -72,6 +72,7 @@ DIRECTORY VIEWS
|
|
72
72
|
G = Show git status for current directory
|
73
73
|
H = Do a cryptographic hash of the current directory with subdirs
|
74
74
|
If a previous hash was made, compare and report if there has been any change
|
75
|
+
S = Show comprehensive system info (system, CPU, filesystem, latest dmesg messages)
|
75
76
|
|
76
77
|
RIGHT PANE
|
77
78
|
ENTER = Refresh the right pane
|
@@ -123,6 +124,7 @@ begin # BASIC SETUP
|
|
123
124
|
require 'fileutils'
|
124
125
|
require 'io/console'
|
125
126
|
require 'date'
|
127
|
+
require 'timeout'
|
126
128
|
require 'curses'
|
127
129
|
include Curses
|
128
130
|
|
@@ -186,7 +188,7 @@ begin # BASIC SETUP
|
|
186
188
|
end
|
187
189
|
end
|
188
190
|
class Curses::Window # CLASS EXTENSION
|
189
|
-
attr_accessor :fg, :bg, :attr, :text, :update, :pager, :pager_more, :pager_cmd, :locate, :nohistory
|
191
|
+
attr_accessor :fg, :bg, :attr, :text, :update, :pager, :pager_more, :pager_cmd, :locate, :nohistory
|
190
192
|
# General extensions (see https://github.com/isene/Ruby-Curses-Class-Extension)
|
191
193
|
def clr
|
192
194
|
self.setpos(0, 0)
|
@@ -226,12 +228,12 @@ def get_ls_color(type) # GET THE COLOR FOR THE FILETYPE FROM IMPORTED LS_COLORS
|
|
226
228
|
return color.to_i, bold
|
227
229
|
end
|
228
230
|
def color_parse(input) # PARSE ANSI COLOR SEQUENCES
|
229
|
-
input.gsub!( /\e\[\d;38;5;(\d+)m/, '
|
230
|
-
input.gsub!( /\e\[38;5;(\d+)m/, '
|
231
|
+
input.gsub!( /\e\[\d;38;5;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
|
232
|
+
input.gsub!( /\e\[38;5;(\d+);*(\d*)m/, '¤¤\1¤¤\2¤¤')
|
231
233
|
input.gsub!( /\e\[0m/, "\t")
|
232
|
-
color_array = input.split("
|
234
|
+
color_array = input.split("¤¤")
|
233
235
|
color_array = color_array.drop(1)
|
234
|
-
output = color_array.each_slice(
|
236
|
+
output = color_array.each_slice(3).to_a
|
235
237
|
return output
|
236
238
|
end
|
237
239
|
def getchr # PROCESS KEY PRESSES
|
@@ -274,6 +276,7 @@ def main_getkey # GET KEY FROM USER
|
|
274
276
|
case chr
|
275
277
|
# BASIC KEYS
|
276
278
|
when '?' # Show helptext in right window
|
279
|
+
@w_r.fg = 249
|
277
280
|
w_r_info(@help)
|
278
281
|
@w_b.update = true
|
279
282
|
when 'r' # Refresh all windows
|
@@ -365,6 +368,7 @@ def main_getkey # GET KEY FROM USER
|
|
365
368
|
@w_b.update = true
|
366
369
|
when 'M' # Show marks
|
367
370
|
@marks = @marks.sort.to_h
|
371
|
+
@w_r.fg = 147
|
368
372
|
marks_info
|
369
373
|
@w_r.update = false
|
370
374
|
@w_b.update = true
|
@@ -438,6 +442,7 @@ def main_getkey # GET KEY FROM USER
|
|
438
442
|
@w_r.update = true
|
439
443
|
@w_b.update = true
|
440
444
|
when 'T' # Show tagged list
|
445
|
+
@w_r.fg = 196
|
441
446
|
tagged_info
|
442
447
|
@w_r.update = false
|
443
448
|
@w_b.update = true
|
@@ -522,6 +527,7 @@ def main_getkey # GET KEY FROM USER
|
|
522
527
|
when 'O' # Show the Ordering in the bottom window (the full ls command)
|
523
528
|
w_b_info(" Full 'ls' command: ls <@s> #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}")
|
524
529
|
when 'G' # Git status for selected item or current dir
|
530
|
+
@w_r.fg = 214
|
525
531
|
if File.exist?(".git")
|
526
532
|
w_r_info(`git status 2>/dev/null`)
|
527
533
|
else
|
@@ -530,6 +536,7 @@ def main_getkey # GET KEY FROM USER
|
|
530
536
|
@w_r.update = false
|
531
537
|
@w_b.update = true
|
532
538
|
when 'H' # Compare with previous hash status or write hash status if no existing hash
|
539
|
+
@w_r.fg = 213
|
533
540
|
hashcmd = "\(find #{Dir.pwd} -type f -print0 | sort -z | xargs -0 sha1sum; find #{Dir.pwd}"\
|
534
541
|
" \\( -type f -o -type d \\) -print0 | sort -z | xargs -0 stat -c '%n %a'\) | sha1sum | cut -c -40"
|
535
542
|
begin
|
@@ -552,6 +559,31 @@ def main_getkey # GET KEY FROM USER
|
|
552
559
|
end
|
553
560
|
@w_r.update = true
|
554
561
|
@w_b.update = false
|
562
|
+
when 'S' # Show comprehensive system info
|
563
|
+
@w_r.pager_cmd = ""
|
564
|
+
uname = `uname -o`.chop + " "
|
565
|
+
uname += `uname -r`.chop + " "
|
566
|
+
uname += `uname -v`.chop + " "
|
567
|
+
uname += `uname -p` + "\n"
|
568
|
+
text = [[253, 1, uname]]
|
569
|
+
mem = `free -h` + "\n"
|
570
|
+
text += [[229, 0, mem]]
|
571
|
+
cpu = "CPUs = " + `nproc`.chop + " "
|
572
|
+
cpuinfo = `lscpu`
|
573
|
+
cpu += cpuinfo[/^.*Model name:\s*(.*)/, 1] + " "
|
574
|
+
cpu += "Max: " + cpuinfo[/^.*CPU max MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
|
575
|
+
cpu += "Min: " + cpuinfo[/^.*CPU min MHz:\s*(.*)/, 1][/(.*),.*/, 1] + "MHz "
|
576
|
+
cpu += "\n\n"
|
577
|
+
text += [[154, 0, cpu]]
|
578
|
+
disk = `df -H`
|
579
|
+
text += [[123, 0, disk]]
|
580
|
+
dmesg = "\nDMESG:\n"
|
581
|
+
dmesg += `dmesg | tail -10`
|
582
|
+
text += [[213, 0, dmesg]]
|
583
|
+
@w_r.text= ansifix(text)
|
584
|
+
pager_start
|
585
|
+
pager_show
|
586
|
+
@w_r.update = false
|
555
587
|
# RIGHT PANE
|
556
588
|
when 'ENTER' # Refresh right pane
|
557
589
|
@w_r.clr # First clear the window, then clear any previously showing image
|
@@ -670,6 +702,16 @@ def conf_write
|
|
670
702
|
end
|
671
703
|
File.write(Dir.home+'/.rtfm.conf', conf)
|
672
704
|
end
|
705
|
+
def ansifix(text) # Format [[fg, attr, text]]
|
706
|
+
output = ""
|
707
|
+
text.each do |e|
|
708
|
+
ansi = "\e[38;5;#{e[0]}"
|
709
|
+
ansi += ";1" if e[1] == 1
|
710
|
+
ansi += "m"
|
711
|
+
output += ansi + e[2].gsub(/\n/, "\n#{ansi}")
|
712
|
+
end
|
713
|
+
return output
|
714
|
+
end
|
673
715
|
# TOP WINDOW FUNCTIONS
|
674
716
|
def w_t_info # SHOW INFO IN @w_t
|
675
717
|
text = " " + ENV['USER'].to_s + "@" + `hostname 2>/dev/null`.to_s.chop + ": " + Dir.pwd + "/"
|
@@ -930,7 +972,7 @@ def w_r_info(info) # SHOW INFO IN THE RIGHT WINDOW
|
|
930
972
|
image_show("clear") if @image; @image = false
|
931
973
|
end
|
932
974
|
def marks_info # SHOW MARKS IN RIGHT WINDOW
|
933
|
-
info = "
|
975
|
+
info = "MARKS:\n"
|
934
976
|
unless @marks.empty?
|
935
977
|
@marks.each do |mark, dir|
|
936
978
|
info += "#{mark} = #{dir}\n"
|
@@ -941,19 +983,21 @@ def marks_info # SHOW MARKS IN RIGHT WINDOW
|
|
941
983
|
w_r_info(info)
|
942
984
|
end
|
943
985
|
def tagged_info # SHOW THE LIST OF TAGGED ITEMS IN @w_r
|
944
|
-
info = "
|
986
|
+
info = "TAGGED:\n"
|
945
987
|
@tagged.empty? ? info += "(None)" : info += @tagged.join("\n")
|
946
988
|
w_r_info(info)
|
947
989
|
end
|
948
|
-
def syntax_highlight(input) #
|
990
|
+
def syntax_highlight(input) # SYNTAX HIGHLIGHTING FROM ANSI COLOR CODES
|
949
991
|
color_ary = color_parse(input)
|
950
992
|
color_ary.each do | pair |
|
951
993
|
begin
|
952
994
|
fg = pair[0].to_i
|
953
|
-
|
995
|
+
atr = pair[1].to_i
|
996
|
+
atr == 1 ? atr = Curses::A_BOLD : atr = 0
|
997
|
+
text = pair[2]
|
954
998
|
text.gsub!(/\t/, '')
|
955
999
|
init_pair(fg, fg, 0)
|
956
|
-
@w_r.attron(color_pair(fg)) { @w_r << text }
|
1000
|
+
@w_r.attron(color_pair(fg) | atr) { @w_r << text }
|
957
1001
|
rescue
|
958
1002
|
end
|
959
1003
|
end
|
@@ -1007,10 +1051,17 @@ def pager_show # SHOW THE CURRENT PAGE CONTENT
|
|
1007
1051
|
end_l = beg_l + @w_r.maxy - 2
|
1008
1052
|
input = @w_r.text.lines[beg_l..end_l].join() + "\n"
|
1009
1053
|
input.lines.count > @w_r.maxy - 2 ? @w_r.pager_more = true : @w_r.pager_more = false
|
1010
|
-
if @w_r.pager_cmd.match(/batcat/)
|
1054
|
+
#if @w_r.pager_cmd.match(/batcat/)
|
1055
|
+
if @w_r.text.match(/^\e\[/)
|
1011
1056
|
syntax_highlight(input)
|
1012
1057
|
else
|
1013
|
-
@w_r
|
1058
|
+
if @w_r.fg == nil
|
1059
|
+
init_pair(255, 255, 0)
|
1060
|
+
@w_r.fg = 255
|
1061
|
+
else
|
1062
|
+
init_pair(@w_r.fg, @w_r.fg, 0)
|
1063
|
+
end
|
1064
|
+
@w_r.attron(color_pair(@w_r.fg)) { @w_r << input }
|
1014
1065
|
end
|
1015
1066
|
(@w_r.maxy - @w_r.cury).times {@w_r.deleteln()} # Clear to bottom of window
|
1016
1067
|
pager_add_markers
|
@@ -1177,17 +1228,19 @@ def w_b_exec(cmd) # EXECUTE COMMAND FROM @W_B
|
|
1177
1228
|
return
|
1178
1229
|
end
|
1179
1230
|
begin
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1231
|
+
status = Timeout::timeout(5) {
|
1232
|
+
begin
|
1233
|
+
@w_r.pager_cmd = "#{cmd} | batcat -n --color=always 2>/dev/null"
|
1234
|
+
@w_r.text = `#{@w_r.pager_cmd} 2>/dev/null`
|
1235
|
+
rescue
|
1236
|
+
@w_r.text = `#{cmd} 2>/dev/null`
|
1237
|
+
end
|
1238
|
+
unless @w_r.text == "" or @w_r.text == nil
|
1239
|
+
pager_start
|
1240
|
+
pager_show
|
1241
|
+
@w_r.update = false
|
1242
|
+
end
|
1243
|
+
}
|
1191
1244
|
rescue
|
1192
1245
|
w_b_info(" Failed to execute command (#{cmd})")
|
1193
1246
|
end
|
@@ -1271,7 +1324,10 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
|
|
1271
1324
|
@w_l.setpos(0,0)
|
1272
1325
|
list_dir(true)
|
1273
1326
|
@w_l.refresh
|
1274
|
-
|
1327
|
+
if @w_r.update and @preview
|
1328
|
+
w_r_show
|
1329
|
+
@w_r.fg = 255
|
1330
|
+
end
|
1275
1331
|
Curses.curs_set(1) # Clear residual cursor
|
1276
1332
|
Curses.curs_set(0) # ...from editing files
|
1277
1333
|
@tag = false # Clear tag pattern
|
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: 1.3.
|
4
|
+
version: 1.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geir Isene
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: curses
|
@@ -33,8 +33,7 @@ dependencies:
|
|
33
33
|
description: 'A full featured terminal browser with syntax highlighted files, images
|
34
34
|
shown in the terminal, videos thumbnailed, etc. You can bookmark and jump around
|
35
35
|
easily, delete, rename, copy, symlink and move files. RTFM has a a wide range of
|
36
|
-
other features. New in 1.3.
|
37
|
-
externally removed'
|
36
|
+
other features. New in 1.3.7: Fixed minor bug in syntax highlighting (via batcat)'
|
38
37
|
email: g@isene.com
|
39
38
|
executables:
|
40
39
|
- rtfm
|