rtfm-filemanager 2.0.2 → 2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +299 -0
- data/bin/rtfm +58 -22
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c410aa1b0b696236f9954263caa3d7e670d7ca45da0d45d2e8cb94fc52d895d1
|
4
|
+
data.tar.gz: 6832505f97d8b81010c50905782af9eb2a36709386ee616d06c8f1024d798a54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7901006b50b618083589b017b66cb747d41c42d7bb170c95b00b19ddbdc0aa1d4921ddfe90ed2eebef10e040f0c15b7a1fa4b2557416d0d0d9b6201d34f8267f
|
7
|
+
data.tar.gz: d8666f8f471d72bc19fd27235e191604d09ef2dd7df58a51339fd9ec7c2cfa5ba7714d28a7aa5c8a2217dd5916cd31c3a473f2b31a397f336ba69ef15fce23a6
|
data/README.md
ADDED
@@ -0,0 +1,299 @@
|
|
1
|
+
# RTFM - Ruby Terminal File Manager
|
2
|
+
|
3
|
+
## What?
|
4
|
+
RTFM is a file manager for the terminal written in Ruby. It lets you browse
|
5
|
+
directories and view the content of directories and files. Files are syntax
|
6
|
+
highlighted, images are shown in the terminal, videos are thumbnailed, etc.
|
7
|
+
You can bookmark and jump around easily, delete, rename, copy, symlink and
|
8
|
+
move files. RTFM has a a wide range of other features. Read on for what it can
|
9
|
+
do.
|
10
|
+
|
11
|
+
Note: RTFM works best with the (u)rxvt, xterm and Eterm terminal emulators.
|
12
|
+
|
13
|
+
## Why?
|
14
|
+
RTFM parses your LS_COLORS to ensure color consistency with the terminal experience.
|
15
|
+
|
16
|
+
The idea came to mind as I was working on [a complete
|
17
|
+
LS_COLORS setup](https://github.com/isene/LS_COLORS) with a corresponding
|
18
|
+
ranger theme. But making a separate theme for ranger to mimic a massive
|
19
|
+
LS_COLOR setup is rather stupid. File managers should parse LS_COLORS as
|
20
|
+
default rather than implement their own themes. This became an itch that
|
21
|
+
I kept scratching until I could happily replace ranger two weeks later.
|
22
|
+
|
23
|
+
|
24
|
+
## How?
|
25
|
+
RTFM is a two-pane file manager. You navigate in the left pane and the content
|
26
|
+
of the selected item (directory or file) is shown in the right pane. The right
|
27
|
+
pane is also used to show information such as the currently tagged items, your
|
28
|
+
(book)marks, output from commands, etc.
|
29
|
+
|
30
|
+
You can run any command in the bottom "command line" and have the output
|
31
|
+
presented in the right pane. Use LEFT and RIGHT keys to go back and forth on
|
32
|
+
the command line, HOME to beginning of line, END to end of line, Backspace or
|
33
|
+
Ctrl-h to delete previous character, Ctrl-w to delete previous word, TAB to
|
34
|
+
complete directories and file names and ENTER to issue the command, while
|
35
|
+
Ctrl-u deletes the line. Issuing ENTER on a blank line has no effect.
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
You can install RTFM by simply coloning this repo and put the file `rtfm` in
|
40
|
+
your "bin" directory. Or you can simply run `gem install rtfm-filemanager`.
|
41
|
+
|
42
|
+
There are two basic prerequisites needed: `x11-utils` and `xdotool`. On
|
43
|
+
Ubuntu these would be installed via `apt install x11-utils xdotool`.
|
44
|
+
|
45
|
+
In order to run RTFM (without generating [a bunch of
|
46
|
+
warnings](https://github.com/isene/RTFM/issues/1)), you need to do a `gem
|
47
|
+
install curses` (gets version 1.3.2) instead of installing via `apt install
|
48
|
+
ruby-curses` (gets version 1.2.4-1build1 on Ubuntu 20.04).
|
49
|
+
|
50
|
+
Content of text files are handled by `cat` - or by `bat` if you want beautiful
|
51
|
+
highlighting. Other files are shown via external programs. It is shown if you
|
52
|
+
have the program installed (Debian/Ubuntu family of Linux distros command in
|
53
|
+
last column):
|
54
|
+
|
55
|
+
File type | Requirements | Installation
|
56
|
+
----------------------------|----------------------------------|-------------------------------
|
57
|
+
Syntax highlighting of text | `bat` | `apt install bat`
|
58
|
+
PDFs | `pdftotext` | `apt install poppler-utils`
|
59
|
+
LibreOffice | `odt2txt` | `apt install odt2txt`
|
60
|
+
MS docx | `docx2txt` | `apt install docx2txt`
|
61
|
+
MS pptx | `unzip` | `apt install unzip`
|
62
|
+
MS xlsx | `ssconvert` | `apt install gnumeric`
|
63
|
+
MS doc/xls/ppt | `catdoc`, `xls2csv` and `catppt` | `apt install catdoc`
|
64
|
+
Images | `w3m` and `ImageMagick` | `apt install w3m imagemagick`
|
65
|
+
Video (thumbnails) | `ffmpegthumbnailer` | `apt install ffmpegthumbnailer`
|
66
|
+
|
67
|
+
Install rtfm from scratch with all of the above on Ubuntu:
|
68
|
+
```
|
69
|
+
sudo apt update
|
70
|
+
sudo apt install ruby-full git libncurses-dev x11-utils xdotool bat poppler-utils odt2txt docx2txt catdoc w3m imagemagick ffmpegthumbnailer
|
71
|
+
sudo gem install curses
|
72
|
+
git clone https://github.com/isene/RTFM
|
73
|
+
cd RTFM
|
74
|
+
sudo cp rtfm /usr/bin/
|
75
|
+
cp .rtfm.launch ~/
|
76
|
+
echo "source ~/.rtfm.launch" >> .zshrc # or .bashrc if you run bash as shell
|
77
|
+
```
|
78
|
+
|
79
|
+
## Screenshot
|
80
|
+
|
81
|
+

|
82
|
+
|
83
|
+
## Image preview in the terminal
|
84
|
+
|
85
|
+
RTFM uses w3mimgdisplay (part of the w3m package) to show images in the
|
86
|
+
terminal. Some terminals have an issue with this - either the images don't
|
87
|
+
show, the previous image is not cleared (new image overlaps the previous) or
|
88
|
+
they show for only a flash or a few seconds. The table below shows how the
|
89
|
+
most popular terminals fare with this. An "O" indicates that the terminal is
|
90
|
+
OK, while an "X" indicates that it fails:
|
91
|
+
|
92
|
+
Terminal |Images | No overlap | Images stay
|
93
|
+
--------------|-------|------------|-----------
|
94
|
+
(u)rxvt | O | O | O
|
95
|
+
xterm | O | O | O
|
96
|
+
Eterm | O | O | O
|
97
|
+
kitty | O | O | O
|
98
|
+
alacritty | O | O | X
|
99
|
+
terminology | O | O | X
|
100
|
+
stterm | O | O | X
|
101
|
+
gnome-terminal| O | X |
|
102
|
+
xfce4-terminal| O | X |
|
103
|
+
mate-terminal | O | X |
|
104
|
+
lilyterm | O | X |
|
105
|
+
termit | X | |
|
106
|
+
lxterminal | X | |
|
107
|
+
qterminal | X | |
|
108
|
+
|
109
|
+
|
110
|
+
## Keys
|
111
|
+
|
112
|
+
These are the set of keys to move around and do actions within RTFM:
|
113
|
+
|
114
|
+
### Basic keys
|
115
|
+
|
116
|
+
Key | Description
|
117
|
+
-------|------------------------------------------------------------------
|
118
|
+
? | Show this help text
|
119
|
+
r | Refresh RTFM (recreates all windows. Use on terminal resize or when there is garbage somewhere)
|
120
|
+
R | Reload configuration (~/.rtfm.conf)
|
121
|
+
W | Write parameters to ~/.rtfm.conf (@lsall, @lslong, @lsorder, @lsinvert, @border, @width, @preview, @tagged, @marks)
|
122
|
+
q | Quit
|
123
|
+
Q | QUIT (without writing changes to the config file)
|
124
|
+
|
125
|
+
### Motion
|
126
|
+
|
127
|
+
Key | Description
|
128
|
+
-----------|------------------------------------------------------------------
|
129
|
+
DOWN or j | Go one item down in left pane (rounds to top)
|
130
|
+
UP or k | Go one item up in left pane (rounds to bottom)
|
131
|
+
LEFT or h | Go up one directory level
|
132
|
+
RIGHT or l | Enter directory or open file (using xdg-open or run-mailcap). Use the key 'x' to force open using xdg-open (or run-mailcap). Use 'x' for opening html files in a browser rather than editing the file in your text editor.
|
133
|
+
PgDown | Go one page down in left pane
|
134
|
+
PgUp | Go one page up in left pane
|
135
|
+
END | Go to last item in left pane
|
136
|
+
HOME | Go to first item in left pane
|
137
|
+
|
138
|
+
### Jumping and marks
|
139
|
+
|
140
|
+
Key | Description
|
141
|
+
-------|------------------------------------------------------------------
|
142
|
+
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
|
143
|
+
M | Show marked items in right pane
|
144
|
+
' | 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)
|
145
|
+
/ | Enter search string in bottom window to highlight matching items and jump to the first match
|
146
|
+
\\ | Remove search pattern
|
147
|
+
n | Jump to the next item matched by '/'
|
148
|
+
N | Jump to the previous item matched by '/'
|
149
|
+
~ | Jump to Home directory
|
150
|
+
\> | Follow symlink to the directory where the target resides
|
151
|
+
L | Start 'locate' search for files, then use '#' to jump to desired line/directory
|
152
|
+
|
153
|
+
### Tagging
|
154
|
+
|
155
|
+
Key | Description
|
156
|
+
-------|------------------------------------------------------------------
|
157
|
+
t | Tag item (toggles)
|
158
|
+
Ctrl-t | Add items matching a pattern to list of tagged items (Ctrl-t and then . will tag all items)
|
159
|
+
T | Show currently tagged items in right pane
|
160
|
+
u | Untag all tagged items
|
161
|
+
|
162
|
+
### Manipulate items
|
163
|
+
|
164
|
+
Key | Description
|
165
|
+
-------|------------------------------------------------------------------
|
166
|
+
p | Put (copy) tagged items here
|
167
|
+
P | PUT (move) tagged items here
|
168
|
+
s | Create symlink to tagged items here
|
169
|
+
d | Delete selected item and tagged items. Press 'y' to confirm
|
170
|
+
c | Change/rename selected (adds command to bottom window)
|
171
|
+
|
172
|
+
### Directory views
|
173
|
+
|
174
|
+
Key | Description
|
175
|
+
-------|------------------------------------------------------------------
|
176
|
+
a | Show all (also hidden) items
|
177
|
+
A | Show All info per item (show item attributes)
|
178
|
+
o | Change the order/sorting of directories (circular toggle)
|
179
|
+
i | Invert/reverse the sorting
|
180
|
+
O | Show the Ordering in the bottom window (the full ls command)
|
181
|
+
G | Show git status for current directory
|
182
|
+
H | Do a cryptographic hash of the current directory with subdirs. If a previous hash was made, compare and report if there has been any change
|
183
|
+
I | Show OpenAI's description of the selected item and its content (if available). You must have installed the ruby-openai gem and added your openai secret key in the .rtfm.conf (add `@ai = "your-secret-openai-key") for this to work. If RTFM is installed as a gem, the ruby-openai gem is included in the installation
|
184
|
+
|
185
|
+
### Right pane
|
186
|
+
|
187
|
+
Key | Description
|
188
|
+
-------|------------------------------------------------------------------
|
189
|
+
ENTER | Refresh the right pane
|
190
|
+
TAB | Next page of the preview (if doc long and ∇ in the bottom right)
|
191
|
+
S-TAB | Previous page (if you have moved down the document first - ∆ in the top right)
|
192
|
+
w | Change the width of the left/right panes (left pane ⇒ ⅓ ⇒ ¼ ⇒ ⅕ ⇒ ⅙ ⇒ ½ ⇒ ⅓)
|
193
|
+
\- | Toggle preview in right pane (turn it off for faster traversing of directories)
|
194
|
+
_ | Toggle preview of images in right pane
|
195
|
+
|
196
|
+
### Additinal commands
|
197
|
+
|
198
|
+
Key | Description
|
199
|
+
-------|------------------------------------------------------------------
|
200
|
+
f | Show only files in the left pane matching extension(s) (e.g. "txt" or "pdf,png,jpg")
|
201
|
+
F | Show only files matching a pattern (Ruby Regex) (e.g. "abc" or "ab.+12(\w3)*")
|
202
|
+
g | Run 'grep' to show files that contains the MATCH in current directory
|
203
|
+
: | Enter "command mode" in bottom window (press ENTER to execute, press Ctrl-G to escape)
|
204
|
+
; | Show command history in right pane
|
205
|
+
y | Copy path of selected item to primary selection (for pasting with middle mouse button)
|
206
|
+
Y | Copy path of selected item to clipboard
|
207
|
+
S | Show comprehensive system info (system, CPU, filesystem, latest dmesg messages)
|
208
|
+
|
209
|
+
|
210
|
+
## A convenient shell function
|
211
|
+
Add this line to your `.bashrc` or `.zshrc` to make RTFM exit to the current
|
212
|
+
directory by launching the file manager via `r` in the terminal:
|
213
|
+
|
214
|
+
`source ~/.rtfm.launch`
|
215
|
+
|
216
|
+
... and place the file `.rtfm.launch` in your home directory.
|
217
|
+
|
218
|
+
With this, you can jump around in your directory structure via RTFM, exit to
|
219
|
+
the desired directory, do work in the terminal and go back into RTFM via `r`.
|
220
|
+
|
221
|
+
|
222
|
+
## Configuration file
|
223
|
+
When you first exit RTFM, it will write your (book)marks and the set of tagged
|
224
|
+
files to `.rtfm.conf`. This ensures your marks and tagged files are
|
225
|
+
persistent. It also means you can launch rtfm tag a bunch of dirs and files,
|
226
|
+
drop out back to the terminal to do some work, back into rtfm and resume to
|
227
|
+
work with your previously tagged items.
|
228
|
+
|
229
|
+
You can also set persistent variables in the config file manually. At the top
|
230
|
+
of `.rtfm.conf` you can set the following:
|
231
|
+
|
232
|
+
To have long info per item: `@lslong = true` (this is otherwise set to `false`)
|
233
|
+
|
234
|
+
To show hidden files: `@lsall = "-a"` (this is otherwise set to `""`)
|
235
|
+
|
236
|
+
To set any additional 'ls' switches, set the variable `@lsuser`. To not list
|
237
|
+
any files containg the word "test", you could do this:
|
238
|
+
```
|
239
|
+
@lsuser = "--ignore=test"
|
240
|
+
```
|
241
|
+
|
242
|
+
To change the default width of the left pane to something other than ⅓rd of
|
243
|
+
the terminal width: `@width = 5` (would set the left pane width to ⅕th).
|
244
|
+
|
245
|
+
To add borders in RTFM: `@border = true`
|
246
|
+
|
247
|
+
To have some commands already prepared for the command history, you can set:
|
248
|
+
```
|
249
|
+
@history = ["cat /home/me/MyTodo.txt", "neofetch --stdout"]
|
250
|
+
```
|
251
|
+
To open files with `run-mailcap` instead of `open-xdg` set:
|
252
|
+
```
|
253
|
+
@runmailcap = true
|
254
|
+
```
|
255
|
+
|
256
|
+
These variables that you manually add to the top of the config files are
|
257
|
+
undisturbed by launching and exiting RTFM.
|
258
|
+
|
259
|
+
You can also use `W` inside of RTFM to write all the parameters mentioned
|
260
|
+
above to the config file - instead of adding them manually.
|
261
|
+
|
262
|
+
To exit RTFM without writing any changes to you marks or list of tagged items,
|
263
|
+
exit with `Q`. They will then remain the same as when you launched RTFM for
|
264
|
+
that session.
|
265
|
+
|
266
|
+
|
267
|
+
## Extra info
|
268
|
+
The top line shows information about the currently item in the left pane. When
|
269
|
+
you are at a file, the information is pretty self explanatory:
|
270
|
+
|
271
|
+
`Path: /home/geir/RTFM/README.md (-rw-rw-r-- 6,0K)`
|
272
|
+
|
273
|
+
This shows the full path of the selected file as well as the permissions and
|
274
|
+
the size of the file. When you are at a directory in the left pane, you get
|
275
|
+
two numbers in brackets. The first number is the number of regular dirs/files
|
276
|
+
in that directory. The second shows the total number of entries, including the
|
277
|
+
hidden directories and files:
|
278
|
+
|
279
|
+
`Path: /home/geir/RTFM (drwxrwxr-x 4,0K) [4 8]`
|
280
|
+
|
281
|
+
Different file types may have extra self explanatory information included in
|
282
|
+
square brackets at the end of the top info line. Image files will have the
|
283
|
+
size of the image included while pdf files will have the number of pages. More
|
284
|
+
file specific information will be included when I feel like adding such.
|
285
|
+
|
286
|
+
## Screencast
|
287
|
+
[](https://youtu.be/ANUOlDryUng)
|
288
|
+
|
289
|
+
|
290
|
+
## Development
|
291
|
+
I don't expect this program to be used by others. I do this for my own
|
292
|
+
enjoyment and because I want a file manager that fits my needs better than any
|
293
|
+
others I have found. If you come up with a feature request I feel is cool, I
|
294
|
+
may include it. Bug reports are always welcome.
|
295
|
+
|
296
|
+
A note to developers: You can hit the "@" key to enter the Ruby debug mode
|
297
|
+
where anything you enter in the bottom command window will be sent to the Ruby
|
298
|
+
eval() function and output to the right pane. You can for instance issue
|
299
|
+
`puts @searched` to see the currently active search pattern.
|
data/bin/rtfm
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
|
-
|
3
|
+
#
|
4
4
|
# SCRIPT INFO
|
5
5
|
# Name: RTFM - Ruby Terminal File Manager
|
6
6
|
# Language: Pure Ruby, best viewed in VIM
|
@@ -48,11 +48,11 @@ JUMPING AND MARKS
|
|
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
50
|
/ = Enter search string in bottom window to highlight matching items and jump to the first match
|
51
|
-
|
51
|
+
\ = Remove search pattern
|
52
52
|
n = Jump to the next item matched by '/'
|
53
53
|
N = Jump to the previous item matched by '/'
|
54
54
|
~ = Jump to Home directory
|
55
|
-
|
55
|
+
> = Follow symlink to the directory where the target resides
|
56
56
|
L = Start 'locate' search for files, then use '#' to jump to desired line/directory
|
57
57
|
|
58
58
|
TAGGING
|
@@ -77,7 +77,6 @@ DIRECTORY VIEWS
|
|
77
77
|
G = Show git status for current directory
|
78
78
|
H = Do a cryptographic hash of the current directory with subdirs
|
79
79
|
If a previous hash was made, compare and report if there has been any change
|
80
|
-
S = Show comprehensive system info (system, CPU, filesystem, latest dmesg messages)
|
81
80
|
I = Show OpenAI's description of the selected item and its content (if available)
|
82
81
|
You must have installed the ruby-openai gem and added your openai secret key
|
83
82
|
in the .rtfm.conf (add `@ai = "your-secret-openai-key") for this to work.
|
@@ -87,19 +86,21 @@ RIGHT PANE
|
|
87
86
|
TAB = Next page of the preview (if doc long and ∇ in the bottom right)
|
88
87
|
S-TAB = Previous page (if you have moved down the document first - ∆ in the top right)
|
89
88
|
w = Change the width of the left/right panes (left pane ⇒ ⅓ ⇒ ¼ ⇒ ⅕ ⇒ ⅙ ⇒ ½ ⇒ ⅓)
|
90
|
-
- = Toggle preview in right pane (turn it off for faster traversing of directories)
|
91
|
-
_ = Toggle preview of images in right pane
|
89
|
+
- = (Minus sign) Toggle preview in right pane (turn it off for faster traversing of directories)
|
90
|
+
_ = (Underscore) Toggle preview of images in right pane
|
92
91
|
|
93
92
|
ADDITINAL COMMANDS
|
93
|
+
f = Show only files in the left pane matching extension(s) (e.g. "txt" or "pdf,png,jpg")
|
94
|
+
F = Show only files matching a pattern (Ruby Regex) (e.g. "abc" or "ab.+12(\w3)*")
|
94
95
|
g = Run 'grep' to show files that contains the MATCH in current directory
|
95
96
|
: = Enter "command mode" in bottom window (press ENTER to execute, press Ctrl-G to escape)
|
96
97
|
; = Show command history in right pane
|
97
98
|
y = Copy path of selected item to primary selection (for pasting with middle mouse button)
|
98
99
|
Y = Copy path of selected item to clipboard
|
100
|
+
S = Show comprehensive System info (system, CPU, filesystem, latest dmesg messages)
|
99
101
|
|
100
102
|
COPYRIGHT: Geir Isene, 2020-3. No rights reserved. See http://isene.com for more.
|
101
103
|
HELPTEXT
|
102
|
-
|
103
104
|
@firstrun = <<FIRSTRUN
|
104
105
|
|
105
106
|
Welcome to RTFM - the Ruby Terminal File Manager. This help text is shown on the first run.
|
@@ -118,7 +119,6 @@ Viewing Images uses "w3m and ImageMagick": apt install w3m imagem
|
|
118
119
|
Viewing Video thumbnails uses "ffmpegthumbnailer" apt install ffmpegthumbnailer
|
119
120
|
|
120
121
|
FIRSTRUN
|
121
|
-
|
122
122
|
unless File.exist?(Dir.home+'/.rtfm.conf')
|
123
123
|
puts @firstrun
|
124
124
|
puts "... hit ENTER to show the RTFM help text."
|
@@ -127,7 +127,6 @@ unless File.exist?(Dir.home+'/.rtfm.conf')
|
|
127
127
|
puts "\n... hit ENTER to start RTFM. Enjoy :-)"
|
128
128
|
STDIN.gets
|
129
129
|
end
|
130
|
-
|
131
130
|
begin # BASIC SETUP
|
132
131
|
require 'fileutils'
|
133
132
|
require 'io/console'
|
@@ -181,6 +180,8 @@ begin # BASIC SETUP
|
|
181
180
|
## These should not be set by user in .rtfm.conf
|
182
181
|
@directory = {} # Initialize the directory hash for remembering directories visited
|
183
182
|
@searched = "" # Initialize the active searched for items
|
183
|
+
@lsfiles = "" # File types to show (initially set to all file types) - not saved on exit
|
184
|
+
@lsmatch = "" # Files to match (initially set to matching all files) - not saved on exit
|
184
185
|
@index = 0 # Set chosen item to first on startup
|
185
186
|
@marks["'"] = Dir.pwd
|
186
187
|
## File type recognizers
|
@@ -431,7 +432,7 @@ def main_getkey # GET KEY FROM USER
|
|
431
432
|
Dir.chdir
|
432
433
|
@w_r.update = true
|
433
434
|
@w_b.update = true
|
434
|
-
when '
|
435
|
+
when '>' # Follow symlink
|
435
436
|
@directory[Dir.pwd] = @selected # Store this directory before leaving
|
436
437
|
mark_latest
|
437
438
|
if File.symlink?(@selected)
|
@@ -683,6 +684,13 @@ def main_getkey # GET KEY FROM USER
|
|
683
684
|
getch
|
684
685
|
@break = true
|
685
686
|
# ADDITIONAL COMMANDS
|
687
|
+
when 'f' # Filter out filetypes not matching @lsfiles
|
688
|
+
loop do
|
689
|
+
@lsfiles = w_b_getstr("Filetype(s) to show: ", @lsfiles)
|
690
|
+
break if @lsfiles.match(/^$|\w+(,\w+)*$/)
|
691
|
+
end
|
692
|
+
when 'F' # Filter out files not matching @lsmatch
|
693
|
+
@lsmatch = w_b_getstr("Files will match RegEx: ", @lsmatch)
|
686
694
|
when '/' # Get search string to mark items that match the input
|
687
695
|
@w_b.nohistory = true
|
688
696
|
@searched = w_b_getstr("/ ", "")
|
@@ -819,6 +827,31 @@ def mark_latest
|
|
819
827
|
@marks["1"] = @marks["'"]
|
820
828
|
@marks["'"] = Dir.pwd
|
821
829
|
end
|
830
|
+
def get_files(win) # The core of the directory listings
|
831
|
+
ls_cmd = "ls #{@lsbase} #{@lsall} #{@lsorder} #{@lsinvert} #{@lsuser}" # Get files in current directory
|
832
|
+
ls_cmd += @selected_safe if win == "right"
|
833
|
+
@files = `#{ls_cmd} 2>/dev/null`.split("\n")
|
834
|
+
ls_cmd += " -H " if win == "right"
|
835
|
+
ls_cmd += %q[ -lhgG --time-style="long-iso" 2>/dev/null | awk '{printf "%s%12s%6s%6s%5s", $1,$4,$5,$3,$2 "\n"}']
|
836
|
+
@fspes = `#{ls_cmd} 2>/dev/null`.split("\n").drop(1)
|
837
|
+
if @lsfiles != "" or @lsmatch != ""
|
838
|
+
lsf = @lsfiles.split(",").map! {|e| e.strip}
|
839
|
+
dir_cmd = "ls -d "
|
840
|
+
dir_cmd += @selected_safe + "/" if win == "right"
|
841
|
+
dir_cmd += "*/"
|
842
|
+
dirs = `#{dir_cmd} 2>/dev/null`.split("/\n")
|
843
|
+
dirs.map!{|d| d.sub!(/.*\//, '')} if win == "right"
|
844
|
+
@files = @files - dirs
|
845
|
+
@fspes = @fspes - dirs
|
846
|
+
@files.select! {|f| lsf.any? {|l| File.extname(f) == ".#{l}"}} if @lsfiles != ""
|
847
|
+
@fspes.select! {|f| lsf.any? {|l| File.extname(f) == ".#{l}"}} if @lsfiles != ""
|
848
|
+
@files.select! {|f| f =~ /#{@lsmatch}/} if @lsmatch != ""
|
849
|
+
@fspes.select! {|f| f =~ /#{@lsmatch}/} if @lsmatch != ""
|
850
|
+
@files = dirs + @files
|
851
|
+
@fspes = dirs + @fspes
|
852
|
+
@w_r.update = true
|
853
|
+
end
|
854
|
+
end
|
822
855
|
# TOP WINDOW FUNCTIONS
|
823
856
|
def w_t_info # SHOW INFO IN @w_t
|
824
857
|
text = " " + ENV['USER'].to_s + "@" + `hostname 2>/dev/null`.to_s.chop + ": " + Dir.pwd + "/"
|
@@ -998,10 +1031,7 @@ def w_r_show # SHOW CONTENTS IN THE RIGHT WINDOW
|
|
998
1031
|
if @w_r.pager > 0
|
999
1032
|
pager_show
|
1000
1033
|
elsif File.directory?(@selected)
|
1001
|
-
|
1002
|
-
@files = `#{ls_cmd} 2>/dev/null`.split("\n")
|
1003
|
-
ls_cmd += %q[ -lhgGH --time-style="long-iso" | awk '{printf "%s%12s%6s%6s%5s", $1,$4,$5,$3,$2 "\n"}']
|
1004
|
-
@fspes = `#{ls_cmd} 2>/dev/null`.split("\n").drop(1)
|
1034
|
+
get_files("right")
|
1005
1035
|
list_dir(false)
|
1006
1036
|
# TEXT
|
1007
1037
|
elsif File.read(@selected).force_encoding("UTF-8").valid_encoding? and @w_r.pager == 0
|
@@ -1076,7 +1106,7 @@ end
|
|
1076
1106
|
def w_r_info(info) # SHOW INFO IN THE RIGHT WINDOW
|
1077
1107
|
image_show("clear") if @image; @image = false
|
1078
1108
|
@w_r.clr
|
1079
|
-
@w_r.
|
1109
|
+
@w_r.refresh
|
1080
1110
|
w_r_width = Curses.cols - (Curses.cols/@width) - 2
|
1081
1111
|
info.gsub!(/(.{1,#{w_r_width}})( +|$\n?)|(.{1,#{w_r_width}})/, "\\1\\3\n")
|
1082
1112
|
@w_r.text = info
|
@@ -1205,7 +1235,11 @@ def openai # INTERFACE TO OPENAI
|
|
1205
1235
|
p += "Give a brief summary of its content: " + c unless File.directory?(@selected) and c == ""
|
1206
1236
|
|
1207
1237
|
response = client.completions( parameters: { model: "text-davinci-003", prompt: p, max_tokens: 200 })
|
1208
|
-
|
1238
|
+
begin
|
1239
|
+
text = "OpenAI description:\n" + response["choices"][0]["text"]
|
1240
|
+
rescue
|
1241
|
+
text = "No OpenAI response"
|
1242
|
+
end
|
1209
1243
|
|
1210
1244
|
@w_r.fg = 229
|
1211
1245
|
w_r_info(text)
|
@@ -1214,7 +1248,11 @@ end
|
|
1214
1248
|
# BOTTOM WINDOW FUNCTIONS
|
1215
1249
|
def w_b_info(info) # SHOW INFO IN @W_B
|
1216
1250
|
@w_b.clr
|
1217
|
-
|
1251
|
+
if info == nil
|
1252
|
+
info = ": for command (use @s for selected item, @t for tagged items) - press ? for help"
|
1253
|
+
info = "Showing only file type #{@lsfiles}" if @lsfiles != ""
|
1254
|
+
info = "Showing only file types #{@lsfiles}" if @lsfiles =~ /,/
|
1255
|
+
end
|
1218
1256
|
info = info[1..(@w_b.maxx - 3)] + "…" if info.length + 3 > @w_b.maxx
|
1219
1257
|
info += " " * (@w_b.maxx - info.length) if info.length < @w_b.maxx
|
1220
1258
|
@w_b.text = info
|
@@ -1404,7 +1442,6 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
|
|
1404
1442
|
@w_p.refresh
|
1405
1443
|
@w_t.fg, @w_t.bg = 232, 249
|
1406
1444
|
@w_t.attr = Curses::A_BOLD
|
1407
|
-
@w_b.fg, @w_b.bg = 250, 238
|
1408
1445
|
@w_b.update = true
|
1409
1446
|
@w_r.update = true
|
1410
1447
|
@w_r.pager = 0
|
@@ -1418,16 +1455,15 @@ loop do # OUTER LOOP - CATCHING REFRESHES VIA 'r'
|
|
1418
1455
|
@change = true
|
1419
1456
|
@change_tag = true # For future need to force @change
|
1420
1457
|
loop do # INNER, CORE LOOP
|
1458
|
+
@w_b.fg, @w_b.bg = 250, 238
|
1459
|
+
@w_b.fg, @w_b.bg = 250, 88 if @lsfiles != ""
|
1421
1460
|
@w_r.text = ""
|
1422
1461
|
begin # Jump to home dir if current dir is externally removed
|
1423
1462
|
Dir.pwd
|
1424
1463
|
rescue
|
1425
1464
|
Dir.chdir
|
1426
1465
|
end
|
1427
|
-
|
1428
|
-
@files = `#{ls_cmd} 2>/dev/null`.split("\n")
|
1429
|
-
ls_cmd += %q[ -lhgG --time-style="long-iso" | awk '{printf "%s%12s%6s%6s%5s", $1,$4,$5,$3,$2 "\n"}']
|
1430
|
-
@fspes = `#{ls_cmd} 2>/dev/null`.split("\n").drop(1)
|
1466
|
+
get_files("left")
|
1431
1467
|
if Dir.pwd != dir_old
|
1432
1468
|
if @directory.key?(Dir.pwd)
|
1433
1469
|
@selected = @directory[Dir.pwd]
|
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.
|
4
|
+
version: '2.2'
|
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-
|
11
|
+
date: 2023-03-22 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.
|
50
|
+
other features. New in 2.1: Added keys ''f'' (show only file types) and ''F'' (show
|
51
|
+
only files matching a RegEx) and moved follow-symlink from ''f'' to ''>''.'
|
51
52
|
email: g@isene.com
|
52
53
|
executables:
|
53
54
|
- rtfm
|
@@ -55,6 +56,7 @@ extensions: []
|
|
55
56
|
extra_rdoc_files: []
|
56
57
|
files:
|
57
58
|
- ".rtfm.launch"
|
59
|
+
- README.md
|
58
60
|
- bin/rtfm
|
59
61
|
homepage: https://isene.com/
|
60
62
|
licenses:
|