rtfm-filemanager 5 → 5.1.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +57 -1
  3. data/bin/rtfm +16 -4
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6057bc9ae7f88f3b05029fe3de2529d72279620808f04e040de4ae38844d31e4
4
- data.tar.gz: ade554a33f58d9ac4543a9582f8f5aa707a2a18ebd76822c19b6ec4e15d175a2
3
+ metadata.gz: 65f531af0c85c52e34c30c9c519d1e6a18805b4a14dc164db763b2222ccdb47b
4
+ data.tar.gz: e33f6bca4bf995ec4409788943ebeb201835d6688d491df5373cbec567947131
5
5
  SHA512:
6
- metadata.gz: da784ee1fedec71ef87abcec3760a5cec1ec803938123556982c860894ace9ed7076fefefe153ca60c37c06c7291c89a5c1111f06fde429bbedf1d5f5c14b1f0
7
- data.tar.gz: f599aa1dd8d1b70977655bd9a2c655f19517c3ef9897eda78e2aa8197674a4343f4bbd22b6829641e18fe09f019b00787a2fd85d1103541a31b45612d91c1ee5
6
+ metadata.gz: 26bfb3dec1c73fb827cab5546463dffc2b08e248e5c626ba94d5fe41ad5ad7caaf5adb9f2ec81d76599d4de98132fd66e5fda4427f86723eda26361e6736e343
7
+ data.tar.gz: 20521351d0b775b30a7cad7d97d40973df535fb5299fa35b0744ed45b5d7f4c1a4fc42c418657d504cd7642885fad0c09e9a0a035c5280efc4687144797add39
data/README.md CHANGED
@@ -473,7 +473,7 @@ RTFM by following the instructions in `keys.rb`:
473
473
  # KEYMAP['X'] = :my_handler
474
474
  #
475
475
  # def my_handler(chr)
476
- # # anything you likebuse @pB, @pR, Dir.pwd, etc.
476
+ # # anything you like - use @pB, @pR, Dir.pwd, etc.
477
477
  # @pB.say("You pressed X!")
478
478
  # end
479
479
  #
@@ -488,8 +488,64 @@ RTFM by following the instructions in `keys.rb`:
488
488
  # @pB.say("ZAPPED!")
489
489
  # end
490
490
  ```
491
+ Here is another example of what you could add as a plugin:
492
+ ```
493
+ KEYMAP['C-G'] = :git_update
494
+
495
+ def git_update
496
+ @pR.say("Updating...")
497
+ message = @pCmd.ask('Commit message: ', '')
498
+ shellexec("git add . && git commit -m '#{message}' && git push")
499
+ @pB.full_refresh
500
+ end
501
+ ```
491
502
  ***With this, you can mold RTFM to fit your needs better.***
492
503
 
504
+ When writing plugins, there are a few variables you should know:
505
+
506
+ Variable | Description
507
+ ----------|------------------------------------------------------------------
508
+ @pT | Top pane (info bar)
509
+ @pL | Left pane
510
+ @pR | Right pane
511
+ @pB | Bottom pane (status bar)
512
+ @pCmd | Command pane (asking for commands to execute)
513
+ @pSearch | Search pane (prompting for what to search for)
514
+ @pAI | Pane for interacting with (Open)AI
515
+ @pRuby | Ruby debug/command pane
516
+ @selected | The selected item in the Left pane
517
+
518
+ Here are three importan hook-ins to use with your plugins:
519
+
520
+ ### Summary of overlap & choice
521
+ - **Use `command`** when you need to _capture_ output as a value (and optionally handle stderr yourself).
522
+ - **Use `shell`** for fire-and-forget side-effects where you don't care about stdout but still want error reporting.
523
+ - **Use `shellexec`** when you want both stdout and stderr printed into RTFM's Right pane automatically.
524
+
525
+ #### `command(cmd, timeout: 5, return_both: false) → String or [stdout, stderr]`
526
+ - **What it does:** Runs `bash -c cmd`, captures both stdout and stderr, enforces a timeout.
527
+ - **When to use:** Programmatically grab output (and optionally errors) of a shell command (e.g. building directory listings or previews).
528
+ - **Key points:**
529
+ - By default prints stderr into the Right pane and returns stdout.
530
+ - `return_both: true` returns `[stdout, stderr]` instead of auto-printing errors.
531
+ - Times out after `timeout` seconds, killing the process if necessary.
532
+
533
+ #### `shell(cmd, background: false, err: nil) → nil`
534
+ - **What it does:** Fires off `cmd` via `system`, redirecting stderr into a log file (default: `$TMP/rtfm_err.log`), optionally in the background.
535
+ - **When to use:** Run side-effecting commands (e.g. `xdg-open`, `mv`) where you don't need stdout but still want error reporting.
536
+ - **Key points:**
537
+ - If `background: true`, runs `cmd &`.
538
+ - Any stderr output is read from the log and shown via `@pR.say`.
539
+ - Doesn't return command output, errors only.
540
+
541
+ #### `shellexec(cmd, timeout: 10) → nil`
542
+ - **What it does:** A thin wrapper over `command(cmd, timeout:, return_both: true)` that _always_ prints both stdout and stderr into the Right pane.
543
+ - **When to use:** Run a command and echo both its stdout and any errors back to the user—e.g. interactive grep, locate, or other one-off shell tools.
544
+ - **Key points:**
545
+ - Internally calls `command(..., return_both: true)`.
546
+ - Prints stderr first, then stdout.
547
+ - Doesn't return anything to the caller.
548
+
493
549
  ## Screencast
494
550
  Here's a screencast for an early version of RTFM, but it shows the basic stuff:
495
551
  [![RTFM screencast](/img/screenshot.png)](https://youtu.be/ANUOlDryUng)
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 = '5.0' # A full rewrite using https://github.com/isene/rcurses
21
+ @version = '5.1' # Fixed a rare bug on opening $EDITOR
22
22
 
23
23
  # BOOTSNAP {{{1
24
24
  cache_dir = ENV.fetch('BOOTSNAP_CACHE_DIR', File.join(Dir.home, '.rtfm', 'bootsnap-cache'))
@@ -1574,7 +1574,7 @@ def dirlist(left: true) # LIST DIRECTORIES {{{2
1574
1574
  end
1575
1575
  # Map & decorate each colored line
1576
1576
  ls.map!.with_index do |el, i|
1577
- n = el.clean_ansi
1577
+ n = el.to_s.clean_ansi
1578
1578
  n = n.shorten(width - 5).inject('…', -1) if n.pure.length > width - 6
1579
1579
  raw_name = (purels[i] || '').strip
1580
1580
  base = left ? Dir.pwd : dir
@@ -2073,8 +2073,20 @@ def open_selected(html = nil) # OPEN SELECTED ITEM (when pressing RIGHT or via o
2073
2073
  return
2074
2074
  end
2075
2075
  if File.read(@selected).force_encoding('UTF-8').valid_encoding? # Pure text
2076
- system("exec $EDITOR #{Shellwords.escape(@selected)}")
2077
- Rcurses.clear_screen
2076
+ system("stty #{ORIG_STTY} < /dev/tty") # Restore terminal so $EDITOR can take over
2077
+ system('clear < /dev/tty > /dev/tty') # Clear RTFM off the screen
2078
+ Cursor.show
2079
+ editor = ENV.fetch('EDITOR', 'vi') # Launch $EDITOR on the real TTY
2080
+ pid = Process.spawn(editor, Shellwords.escape(@selected),
2081
+ in: '/dev/tty',
2082
+ out: '/dev/tty',
2083
+ err: '/dev/tty')
2084
+ Process.wait(pid)
2085
+ system('stty raw -echo isig < /dev/tty') # Re-enter raw/no-echo mode and hide cursor
2086
+ $stdin.raw!
2087
+ $stdin.echo = false
2088
+ Cursor.hide
2089
+ Rcurses.clear_screen # Redraw RTFM
2078
2090
  refresh
2079
2091
  render
2080
2092
  return
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: '5'
4
+ version: 5.1.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: 2025-04-28 00:00:00.000000000 Z
11
+ date: 2025-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rcurses
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '7.4'
55
55
  description: |-
56
56
  Major release - RTFM v5: Complete rewrite using rcurses (https://github.com/isene/rcurses). Massive improvements. AI integration.
57
- A full featured terminal browser with syntax highlighted files, images shown in the terminal, videos thumbnailed, etc. You can bookmark and jump around easily, delete, rename, copy, symlink and move files. RTFM is one of the most feature-packed terminal file managers.
57
+ A full featured terminal browser with syntax highlighted files, images shown in the terminal, videos thumbnailed, etc. You can bookmark and jump around easily, delete, rename, copy, symlink and move files. RTFM is one of the most feature-packed terminal file managers. 5.1.1: Minor bugfix (fixed calling clean_ansi with nil).
58
58
  email: g@isene.com
59
59
  executables:
60
60
  - rtfm