rtfm-filemanager 7.3.5 → 7.4.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.
data/bin/rtfm CHANGED
@@ -18,7 +18,7 @@
18
18
  # get a great understanding of the code itself by simply sending
19
19
  # or pasting this whole file into you favorite AI for coding with
20
20
  # a prompt like this: "Help me understand every part of this code".
21
- @version = '7.3.5' # Image clearing for directory navigation
21
+ @version = '7.4.0' # Comprehensive documentation release
22
22
 
23
23
  # SAVE & STORE TERMINAL {{{1
24
24
  ORIG_STTY = `stty -g`.chomp
@@ -1198,12 +1198,22 @@ def toggle_border # {{{3
1198
1198
  end
1199
1199
 
1200
1200
  def toggle_preview # {{{3
1201
+ # Clear image BEFORE toggling if we're about to turn preview off
1202
+ if @preview && @image
1203
+ showimage('clear')
1204
+ @image = false
1205
+ end
1201
1206
  @preview = !@preview
1202
1207
  @pB.say("Preview = #{@preview ? 'On' : 'Off'}")
1203
1208
  @pR.clear unless @preview
1204
1209
  end
1205
1210
 
1206
1211
  def toggle_image # {{{3
1212
+ # Clear image BEFORE toggling if we're about to turn it off
1213
+ if @showimage && @image
1214
+ showimage('clear')
1215
+ @image = false
1216
+ end
1207
1217
  @showimage = !@showimage
1208
1218
  @pB.say("Image preview = #{@showimage ? 'On' : 'Off'}")
1209
1219
  getch
@@ -4887,14 +4897,15 @@ def render # RENDER ALL PANES {{{2
4887
4897
  cached_meta = get_cached_file_metadata(@selected)
4888
4898
  if cached_meta
4889
4899
  text += cached_meta
4890
- elsif @selected&.match(@imagefile) && cmd?('identify')
4900
+ elsif @preview && @selected&.match(@imagefile) && cmd?('identify')
4901
+ # Only get image metadata if preview is ON (avoid lag with preview OFF)
4891
4902
  # Skip SVG files as identify can be very slow on them
4892
4903
  unless @selected =~ /\.svg$/i
4893
4904
  # Fallback for non-cached image metadata
4894
4905
  meta = `identify -format " [%wx%h %m %[colorspace] %[bit-depth]-bit]" #{Shellwords.escape(@selected)} 2>/dev/null`
4895
4906
  text += meta
4896
4907
  end
4897
- elsif @selected&.match(@pdffile)
4908
+ elsif @preview && @selected&.match(@pdffile)
4898
4909
  # Fallback for non-cached PDF metadata
4899
4910
  info = `pdfinfo #{Shellwords.escape(@selected)} 2>/dev/null`
4900
4911
  pages = info[/^Pages:\s+(\d+)/, 1]
@@ -5694,6 +5705,7 @@ end
5694
5705
 
5695
5706
  def clear_image(skip_actual_clear: false) # HELPER TO CLEAR CURRENT IMAGE {{{2
5696
5707
  return unless @image
5708
+ return unless @preview # Don't clear if preview is off - nothing to clear
5697
5709
  # For operations that immediately render text over image, skip the slow clear
5698
5710
  # The text pane will cover the image overlay anyway
5699
5711
  unless skip_actual_clear
@@ -5705,6 +5717,7 @@ end
5705
5717
  def showimage(image) # SHOW THE SELECTED IMAGE IN THE RIGHT WINDOW {{{2
5706
5718
  # Pass 'clear' to clear the window for previous image
5707
5719
  return unless @showimage
5720
+ return unless @preview # Don't show images if preview is off
5708
5721
 
5709
5722
  begin
5710
5723
  if image == 'clear'
@@ -0,0 +1,397 @@
1
+ # RTFM Configuration Guide
2
+
3
+ Complete guide to customizing RTFM.
4
+
5
+ ## Configuration File
6
+
7
+ Location: `~/.rtfm/conf`
8
+
9
+ RTFM automatically creates this file on first exit, saving:
10
+ - Bookmarks (@marks)
11
+ - Tagged items
12
+ - Command history
13
+ - Directory hashes
14
+
15
+ ## Viewing Configuration
16
+
17
+ | Action | Key |
18
+ |--------|-----|
19
+ | View current config | `C` |
20
+ | Save config | `W` |
21
+ | Reload config | `R` |
22
+
23
+ ## Core Settings
24
+
25
+ ### Display Options
26
+
27
+ ```ruby
28
+ # Toggle preview in right pane
29
+ @preview = true # false to disable
30
+
31
+ # Toggle image display
32
+ @showimage = true # false to disable
33
+
34
+ # Show hidden files
35
+ @lsall = "-a" # "" to hide hidden files
36
+
37
+ # Show long file info (ls -l format)
38
+ @lslong = true # false for compact view
39
+
40
+ # Pane width ratio (2-7)
41
+ # 2 = narrow left, 7 = wide left
42
+ @width = 5
43
+
44
+ # Border style (0-3)
45
+ # 0 = no borders
46
+ # 1 = right pane only
47
+ # 2 = both panes
48
+ # 3 = left pane only
49
+ @border = 2
50
+
51
+ # Syntax highlighting
52
+ @batuse = true # false to use plain cat
53
+ ```
54
+
55
+ ### File Operations
56
+
57
+ ```ruby
58
+ # Enable trash bin (move to ~/.rtfm/trash instead of permanent delete)
59
+ @trash = true # false for permanent deletion
60
+
61
+ # Use run-mailcap instead of xdg-open
62
+ @runmailcap = true # false to use xdg-open
63
+ ```
64
+
65
+ ### Sorting & Ordering
66
+
67
+ ```ruby
68
+ # Sort order
69
+ @lsorder = "" # "" = name
70
+ # "-S" = size
71
+ # "-t" = time
72
+ # "-X" = extension
73
+
74
+ # Invert sort
75
+ @lsinvert = "" # "-r" to reverse
76
+
77
+ # Additional ls options
78
+ @lsuser = "--ignore=test" # Any valid ls flags
79
+ ```
80
+
81
+ ### File Type Filtering
82
+
83
+ ```ruby
84
+ # Show only specific extensions
85
+ @lsfiles = "txt,md,rb" # Comma-separated extensions
86
+ # "" to show all
87
+ ```
88
+
89
+ ## Color Customization
90
+
91
+ ### Pane Colors
92
+
93
+ ```ruby
94
+ # Bottom pane background
95
+ @bottomcolor = 238
96
+
97
+ # Command mode background
98
+ @cmdcolor = 24
99
+
100
+ # Ruby debug mode background
101
+ @rubycolor = 52
102
+
103
+ # OpenAI chat background
104
+ @aicolor = 17
105
+ ```
106
+
107
+ ### Path-Based Top Bar Colors
108
+
109
+ Change top bar color based on current path:
110
+
111
+ ```ruby
112
+ @topmatch = [
113
+ ["projects", 165], # Blue when path contains "projects"
114
+ ["downloads", 220], # Yellow for downloads
115
+ ["personal", 156], # Green for personal
116
+ ["", 238] # Default gray
117
+ ]
118
+ ```
119
+
120
+ **Order matters:** First match wins. Last entry should have empty string for default.
121
+
122
+ ## Persistent Data
123
+
124
+ ### Bookmarks
125
+
126
+ ```ruby
127
+ # Directory bookmarks (saved automatically)
128
+ @marks = {
129
+ "h" => "/home/user",
130
+ "d" => "/home/user/Documents",
131
+ "p" => "/home/user/projects",
132
+ "0" => "/initial/launch/directory"
133
+ }
134
+ ```
135
+
136
+ **Special marks:**
137
+ - `'` - Last visited directory
138
+ - `0` - Launch directory
139
+ - `1-5` - Last 5 visited directories (auto-managed)
140
+
141
+ ### Command History
142
+
143
+ ```ruby
144
+ # Prepopulate command history
145
+ @history = [
146
+ "git status",
147
+ "ls -la",
148
+ "cat TODO.txt"
149
+ ]
150
+ ```
151
+
152
+ ### Ruby Command History
153
+
154
+ ```ruby
155
+ # Prepopulate Ruby debug history
156
+ @rubyhistory = [
157
+ "puts @selected",
158
+ "puts @tagged.inspect"
159
+ ]
160
+ ```
161
+
162
+ ### OpenAI History
163
+
164
+ ```ruby
165
+ # Prepopulate AI chat history
166
+ @aihistory = [
167
+ "Explain this code",
168
+ "What does this file do?"
169
+ ]
170
+ ```
171
+
172
+ ### SSH Connection History
173
+
174
+ ```ruby
175
+ # Prepopulate SSH connections
176
+ @sshhistory = [
177
+ "user@server.com:/var/www # Production",
178
+ "admin@192.168.1.10 # Local dev"
179
+ ]
180
+ ```
181
+
182
+ ### Directory Hashes
183
+
184
+ ```ruby
185
+ # Cryptographic hashes of directory trees
186
+ # (generated with H key, compared on subsequent runs)
187
+ @hash = {
188
+ "/home/user/important" => "abc123...",
189
+ "/etc/config" => "def456..."
190
+ }
191
+ ```
192
+
193
+ ## Advanced Settings
194
+
195
+ ### Interactive Program Whitelist
196
+
197
+ Programs that take full terminal control must be whitelisted:
198
+
199
+ ```ruby
200
+ @interactive = "htop,vim,emacs,nano,less,ranger,mc"
201
+ ```
202
+
203
+ **Add programs:**
204
+ - Press `+` in RTFM and type program name
205
+ - Or manually add to @interactive
206
+
207
+ **Force interactive mode:**
208
+ - Prefix command with `§`: `:§program`
209
+
210
+ ### OpenAI Integration
211
+
212
+ ```ruby
213
+ # Add your OpenAI API key
214
+ @ai = "sk-your-api-key-here"
215
+ ```
216
+
217
+ **Features enabled:**
218
+ - `I` - Get file description
219
+ - `Ctrl-a` - Start AI chat
220
+
221
+ **Get API key:** https://platform.openai.com/api-keys
222
+
223
+ ### Preview Customization
224
+
225
+ See [plugins.md](plugins.md) for custom preview handlers.
226
+
227
+ ## Configuration Best Practices
228
+
229
+ ### Organized Config File
230
+
231
+ ```ruby
232
+ # ~/.rtfm/conf - Well organized
233
+
234
+ # ============================================================
235
+ # DISPLAY SETTINGS
236
+ # ============================================================
237
+ @preview = true
238
+ @showimage = true
239
+ @batuse = true
240
+ @width = 5
241
+ @border = 2
242
+
243
+ # ============================================================
244
+ # FILE OPERATIONS
245
+ # ============================================================
246
+ @trash = true
247
+ @runmailcap = false
248
+
249
+ # ============================================================
250
+ # SORTING
251
+ # ============================================================
252
+ @lsall = "-a"
253
+ @lslong = false
254
+ @lsorder = ""
255
+ @lsinvert = ""
256
+
257
+ # ============================================================
258
+ # COLORS
259
+ # ============================================================
260
+ @bottomcolor = 238
261
+ @cmdcolor = 24
262
+ @aicolor = 17
263
+
264
+ @topmatch = [
265
+ ["work", 165],
266
+ ["personal", 156],
267
+ ["", 238]
268
+ ]
269
+
270
+ # ============================================================
271
+ # BOOKMARKS (auto-managed, but you can edit)
272
+ # ============================================================
273
+ @marks = {
274
+ "h" => ENV['HOME'],
275
+ "d" => "#{ENV['HOME']}/Documents",
276
+ "w" => "#{ENV['HOME']}/work"
277
+ }
278
+
279
+ # ============================================================
280
+ # HISTORY (auto-managed)
281
+ # ============================================================
282
+ @history = []
283
+ @rubyhistory = []
284
+ @aihistory = []
285
+ @sshhistory = []
286
+
287
+ # ============================================================
288
+ # ADVANCED
289
+ # ============================================================
290
+ @interactive = "htop,vim,nano,emacs,ranger"
291
+ @ai = "" # Add your OpenAI key here
292
+ ```
293
+
294
+ ### Testing Changes
295
+
296
+ After editing `~/.rtfm/conf`:
297
+ 1. Press `R` in RTFM to reload
298
+ 2. Or restart RTFM
299
+
300
+ ### Backing Up Config
301
+
302
+ ```bash
303
+ cp ~/.rtfm/conf ~/.rtfm/conf.backup
304
+ ```
305
+
306
+ ## Terminal-Specific Settings
307
+
308
+ ### urxvt / xterm / Eterm
309
+
310
+ No special configuration needed - works perfectly out of the box.
311
+
312
+ ### kitty
313
+
314
+ Images work with brief flash (w3m protocol limitation with kitty).
315
+
316
+ ### mlterm
317
+
318
+ Best Sixel protocol support - fast inline images.
319
+
320
+ ## Resetting Configuration
321
+
322
+ ```bash
323
+ # Backup current config
324
+ cp ~/.rtfm/conf ~/.rtfm/conf.old
325
+
326
+ # Delete config (will regenerate on next run)
327
+ rm ~/.rtfm/conf
328
+
329
+ # Or reset specific settings
330
+ r # Launch RTFM
331
+ W # Write default config
332
+ ```
333
+
334
+ ## Environment Variables
335
+
336
+ RTFM respects standard environment variables:
337
+
338
+ ```bash
339
+ # Default editor
340
+ export EDITOR=vim
341
+
342
+ # LS_COLORS for terminal theming
343
+ export LS_COLORS="di=1;34:ln=1;36:..."
344
+
345
+ # OpenAI key (alternative to @ai in config)
346
+ export OPENAI_API_KEY="sk-..."
347
+ ```
348
+
349
+ ## Performance Tuning
350
+
351
+ ### For Large Directories
352
+
353
+ ```ruby
354
+ # Turn off preview for faster navigation
355
+ @preview = false
356
+
357
+ # Turn off long info
358
+ @lslong = false
359
+
360
+ # Disable images
361
+ @showimage = false
362
+ ```
363
+
364
+ ### For Slow Networks (SSH)
365
+
366
+ Enable persistent SSH connections in `~/.ssh/config`:
367
+ ```
368
+ Host *
369
+ ControlMaster auto
370
+ ControlPath ~/.ssh/control-%r@%h:%p
371
+ ControlPersist 10m
372
+ ```
373
+
374
+ ## Troubleshooting
375
+
376
+ ### Config File Errors
377
+
378
+ If RTFM won't start after editing config:
379
+
380
+ ```bash
381
+ # Check for syntax errors
382
+ ruby -c ~/.rtfm/conf
383
+
384
+ # Restore backup
385
+ cp ~/.rtfm/conf.backup ~/.rtfm/conf
386
+ ```
387
+
388
+ ### Reset to Defaults
389
+
390
+ ```bash
391
+ mv ~/.rtfm ~/.rtfm.old
392
+ # Restart RTFM - creates fresh config
393
+ ```
394
+
395
+ ---
396
+
397
+ [← Getting Started](getting-started.md) | [Next: Keyboard Reference →](keyboard-reference.md)