rufio 1.5.1 → 2.0.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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +86 -0
  3. data/README.md +18 -6
  4. data/README_ja.md +18 -6
  5. data/Rakefile +5 -0
  6. data/SECURITY.md +16 -8
  7. data/docs/csv_cell_preview_design_ja.md +682 -0
  8. data/docs/guide.md +115 -20
  9. data/docs/guide_ja.md +116 -21
  10. data/docs/image_preview_design_ja.md +335 -0
  11. data/docs/native_fuzzy_search_design_ja.md +684 -0
  12. data/examples/config.rb +23 -0
  13. data/info/help.md +32 -18
  14. data/info/keybindings.md +43 -11
  15. data/info/welcome.md +4 -6
  16. data/lib/rufio/background_status.rb +7 -0
  17. data/lib/rufio/bookmark_controller.rb +0 -45
  18. data/lib/rufio/clipboard.rb +162 -0
  19. data/lib/rufio/command_locator.rb +49 -0
  20. data/lib/rufio/config.rb +7 -4
  21. data/lib/rufio/config_loader.rb +66 -11
  22. data/lib/rufio/csv_table_source.rb +125 -0
  23. data/lib/rufio/encoding_detector.rb +152 -0
  24. data/lib/rufio/file_operation_controller.rb +41 -0
  25. data/lib/rufio/file_preview.rb +92 -19
  26. data/lib/rufio/fuzzy_candidate_block.rb +131 -0
  27. data/lib/rufio/fuzzy_file_source.rb +180 -0
  28. data/lib/rufio/fuzzy_search.rb +327 -0
  29. data/lib/rufio/fuzzy_search_session.rb +426 -0
  30. data/lib/rufio/graphics_layer.rb +223 -0
  31. data/lib/rufio/health_checker.rb +27 -32
  32. data/lib/rufio/help_menu.rb +16 -10
  33. data/lib/rufio/image_preview_view.rb +421 -0
  34. data/lib/rufio/image_source.rb +158 -0
  35. data/lib/rufio/keybind_handler.rb +21 -34
  36. data/lib/rufio/kitty_graphics.rb +128 -0
  37. data/lib/rufio/native/aarch64-linux-gnu/librufio_zig.so +0 -0
  38. data/lib/rufio/native/aarch64-linux-musl/librufio_zig.so +0 -0
  39. data/lib/rufio/native/aarch64-macos/librufio_zig.dylib +0 -0
  40. data/lib/rufio/native/aarch64-windows/rufio_zig.dll +0 -0
  41. data/lib/rufio/native/x86_64-linux-gnu/librufio_zig.so +0 -0
  42. data/lib/rufio/native/x86_64-linux-musl/librufio_zig.so +0 -0
  43. data/lib/rufio/native/x86_64-macos/librufio_zig.dylib +0 -0
  44. data/lib/rufio/native/x86_64-windows/rufio_zig.dll +0 -0
  45. data/lib/rufio/native_content_search.rb +44 -8
  46. data/lib/rufio/native_image.rb +177 -0
  47. data/lib/rufio/native_scanner_zig.rb +39 -0
  48. data/lib/rufio/navigation_controller.rb +47 -16
  49. data/lib/rufio/preview_registry.rb +86 -0
  50. data/lib/rufio/preview_view.rb +363 -0
  51. data/lib/rufio/renderer.rb +8 -8
  52. data/lib/rufio/screen.rb +38 -1
  53. data/lib/rufio/search_prompt.rb +50 -0
  54. data/lib/rufio/search_screen.rb +680 -0
  55. data/lib/rufio/sheet_picker.rb +87 -0
  56. data/lib/rufio/sqlite_table_source.rb +205 -0
  57. data/lib/rufio/tab_mode_manager.rb +1 -3
  58. data/lib/rufio/table_cursor.rb +117 -0
  59. data/lib/rufio/table_document.rb +261 -0
  60. data/lib/rufio/table_layout.rb +231 -0
  61. data/lib/rufio/table_preview_view.rb +376 -0
  62. data/lib/rufio/table_query.rb +240 -0
  63. data/lib/rufio/table_source.rb +46 -0
  64. data/lib/rufio/terminal_graphics.rb +168 -0
  65. data/lib/rufio/terminal_ui.rb +74 -60
  66. data/lib/rufio/text_utils.rb +27 -0
  67. data/lib/rufio/ui_renderer.rb +380 -17
  68. data/lib/rufio/version.rb +1 -1
  69. data/lib/rufio/xlsx_table_source.rb +112 -0
  70. data/lib/rufio.rb +21 -1
  71. data/lib_zig/rufio_native/Makefile +21 -5
  72. data/lib_zig/rufio_native/build.zig +18 -0
  73. data/lib_zig/rufio_native/src/fuzzy.zig +520 -0
  74. data/lib_zig/rufio_native/src/fuzzy_test.zig +212 -0
  75. data/lib_zig/rufio_native/src/image.zig +525 -0
  76. data/lib_zig/rufio_native/src/image_bmp.zig +111 -0
  77. data/lib_zig/rufio_native/src/image_jpeg.zig +878 -0
  78. data/lib_zig/rufio_native/src/image_png.zig +561 -0
  79. data/lib_zig/rufio_native/src/image_resize.zig +170 -0
  80. data/lib_zig/rufio_native/src/image_test.zig +401 -0
  81. data/lib_zig/rufio_native/src/main.zig +28 -0
  82. data/lib_zig/rufio_native/src/search.zig +260 -64
  83. data/lib_zig/rufio_native/src/search_test.zig +35 -0
  84. data/lib_zig/rufio_native/src/testdata/alpha.png +0 -0
  85. data/lib_zig/rufio_native/src/testdata/gradient.bmp +0 -0
  86. data/lib_zig/rufio_native/src/testdata/gradient.jpg +0 -0
  87. data/lib_zig/rufio_native/src/testdata/gradient.png +0 -0
  88. data/retag.sh +4 -4
  89. metadata +44 -5
  90. data/lib/rufio/global_search.rb +0 -412
  91. data/lib/rufio/search_controller.rb +0 -92
  92. data/lib_zig/rufio_native/src/main.zig.sync +0 -205
data/examples/config.rb CHANGED
@@ -74,3 +74,26 @@ COMMAND_HISTORY_SIZE = 1000
74
74
  #
75
75
  # These files are automatically loaded by rufio.
76
76
  # You can edit them manually or manage via rufio's UI.
77
+
78
+ # ========================================
79
+ # Table Preview (.csv / .tsv / .tab)
80
+ # ========================================
81
+ # Limits and display settings for the grid preview.
82
+ # Omitted or out-of-range values fall back to the defaults shown here.
83
+ TABLE_PREVIEW = {
84
+ max_bytes: 512 * 1024, # Bytes read from a .csv / .tsv (up to 4 MiB)
85
+ max_rows: 1000, # Rows parsed
86
+ max_columns: 256, # Columns parsed
87
+ max_column_width: 32, # Display width of one column
88
+ header: true, # Treat the first row as the header
89
+ delimiter: 'auto', # 'auto' (extension, then ';' detection), ',', "\t", ';' ...
90
+ encoding: 'auto' # 'auto' (BOM / UTF-8 / CP932 / EUC-JP), 'UTF-8', 'CP932' ...
91
+ }.freeze
92
+
93
+ # ========================================
94
+ # Clipboard Command (y)
95
+ # ========================================
96
+ # Command that receives the copied text on stdin, as a string or an argv array.
97
+ # Leave it unset to use pbcopy / clip / wl-copy / xclip / xsel when available,
98
+ # and OSC 52 otherwise (works over SSH; in tmux also set -g set-clipboard on).
99
+ # CLIPBOARD_COMMAND = ['xclip', '-selection', 'clipboard'].freeze
data/info/help.md CHANGED
@@ -11,7 +11,7 @@
11
11
  - [Bookmarks & Navigation](#bookmarks--navigation)
12
12
  - [Command Mode](#command-mode)
13
13
  - [Tool Runtime](#tool-runtime)
14
- - [Global Search & Config Mode](#global-search--config-mode)
14
+ - [Search & Config Mode](#search--config-mode)
15
15
  - [Modes & Help Menu](#modes--help-menu)
16
16
 
17
17
  ---
@@ -41,13 +41,26 @@
41
41
  | `d` | Delete file or directory (with confirmation) |
42
42
  | `a` | Create new file |
43
43
  | `A` | Create new directory |
44
+ | `y` | Copy the current or selected paths to the clipboard |
44
45
 
45
- In a preview, `j/k` scroll, `Ctrl+D/U` page down/up and `ESC` returns to the file list.
46
+ In a preview, `j/k` scroll, `Ctrl+D/U` page down/up and `ESC` returns to the file list. `/` searches inside the file: type to jump to the first match, `Enter` keeps it, `n` / `N` move between matches and `ESC` clears the search (another `ESC` leaves the preview). Matches are highlighted, the current one in a different colour.
47
+
48
+ In a table preview, `h/j/k/l` and the arrow keys move a cell cursor instead, `g/}` jump to the first and last row, `0/$` to the first and last column, `Space` selects the column under the cursor (its cells are marked like a selected file), `y` copies the cell under the cursor, or the cursor row's selected columns joined with commas when any column is selected, `Y` the whole row as a CSV line, `[`/`]` switch between a workbook's sheets or a database's tables, `t` opens the list of sheets or tables (`j`/`k` to move, `Enter` to open the selected one, `ESC` to close), `/` filters the rows (see below), and the line under the file name shows the cell address and column name (`R3C2 price`). The grid scrolls in both directions to keep the cursor visible.
49
+
50
+ Copying uses `pbcopy`, `clip`, `wl-copy`, `xclip` or `xsel` when available and OSC 52 otherwise; `CLIPBOARD_COMMAND` in `config.rb` overrides it and `rufio -c` shows which one is used.
46
51
 
47
52
  Text previews read at most the first 64 KiB. PDF bodies are not previewed, keeping file navigation responsive.
48
53
 
54
+ Images (`.png`, `.jpg`, `.bmp`, recognised by the file's own signature) are shown in the preview pane on terminals that speak the Kitty graphics protocol (kitty, Ghostty, WezTerm, Konsole). The pane's cells are left blank and the picture is drawn by the terminal, so the file list stays readable. The bundled native library decodes the image and scales it down to the pane before sending, so a 12 MP photo travels as a few hundred KB; files up to 32 MiB are read. Without that library (or with `RUFIO_NATIVE_IMAGE=0`) PNG files up to 8 MiB are still sent as they are, since terminals decode PNG themselves. On other terminals, inside tmux, for `.gif`, for progressive JPEG or for an interlaced PNG, the format, size and pixel dimensions are shown as text instead. `RUFIO_IMAGE_PREVIEW=0` turns images off.
55
+
56
+ In preview mode (`P`) on an image, `+` and `-` zoom in 25% steps up to 4x, `0` fits the picture to the pane again, and `h/j/k/l` or the arrow keys move around while zoomed (the terminal is asked for a part of the picture, so no decoding is needed). Moving to another file removes the picture first and sends the new one a moment later, so holding `j` through a folder of images does not flood the terminal, and a picture that was painted over by a notification is put back.
57
+
49
58
  `.zip` previews list the archive entries (size, method, modified time, name) without extracting them.
50
59
 
60
+ `/` in a table preview filters its rows. Write conditions separated by commas: `price > 100, name a%` keeps the rows where price is over 100 and the name starts with `a`. A term without a column (`apple`) is searched in every column, `=`, `!=`, `<>`, `>`, `>=`, `<` and `<=` compare (numerically when both sides are numbers), and anything else matches with `LIKE`: `a%` and `a_c` use the wildcards as written, a plain word matches anywhere in the column. Quote a value to keep its commas and spaces (`note "red, sweet"`). Column names ignore case, and the column letters (`A`, `B`, …) work too. `Enter` applies the filter and the line under the file name shows it (`filter: price > 100 (2 rows)`), `ESC` clears it. For a SQLite table the filter runs as a read-only `SELECT ... WHERE` inside the database, so it finds rows past the preview's row limit; a spreadsheet or CSV is filtered over the rows that were read.
61
+
62
+ `.csv`, `.tsv`, `.tab`, `.xlsx`, `.xlsm` and `.ods` files, and SQLite databases when the `sqlite3` command is installed (recognised by the file's own signature, whatever its extension), are shown as a grid with column letters, the header row kept in place while you scroll, and a last line reporting the row and column counts, the detected character encoding and any truncation. UTF-8, UTF-16 (with BOM), CP932 and EUC-JP files are decoded automatically. A `.csv` or `.tsv` is read up to 512 KiB.
63
+
51
64
  ### File Selection & Bulk Operations
52
65
 
53
66
  | Key | Action |
@@ -65,10 +78,14 @@ ZIP jobs show progress in Jobs mode (`J`). `x`: Cancel the selected job there; a
65
78
  | Key | Action |
66
79
  |-----|--------|
67
80
  | `f` | Start filter mode |
68
- | `s` | Search file names with fzf |
69
- | `/` | Search file names with fzf (same as `s`) |
70
- | `F` | Search file contents with rga (ripgrep-all) |
71
- | `G` | Global search: file names or contents across all bookmarks |
81
+ | `/` | Search, scoped to where you are |
82
+
83
+ **Search (`/`):**
84
+ - `/` is the only search key. What it searches depends on the mode: the file list searches the current directory tree, a preview searches inside the file, and a table preview filters its rows
85
+ - In the file list it opens the search screen over every file under the current directory (hidden files included); no external tools are needed. Bookmarks are not searched
86
+ - `Tab`: Switch between fuzzy (in-order, non-contiguous) file names and literal, case insensitive contents. Matched characters are highlighted
87
+ - `Up/Down` or `Ctrl+J/K or Ctrl+N/P`: Select | `Enter`: Go to the file in Files mode | `Ctrl+U`: Clear | `ESC`: Back
88
+ - Content results show the file, the line number and the matching text, and also read `.pdf` (page), `.xlsx` (sheet/cell) and `.pptx` (slide)
72
89
 
73
90
  **Filter Mode:**
74
91
  - Type characters to filter files in real-time
@@ -83,8 +100,6 @@ ZIP jobs show progress in Jobs mode (`J`). `x`: Cancel the selected job there; a
83
100
  | `B` | Bookmark menu (view/add/remove/script paths) |
84
101
  | `0` | Jump to startup directory |
85
102
  | `1-9` | Jump to bookmark 1-9 |
86
- | `Tab` | Cycle to next bookmark (Files mode) |
87
- | `Shift+Tab` | Cycle to previous bookmark (Files mode) |
88
103
  | `z` | Navigate using zoxide history (when nothing is selected) |
89
104
 
90
105
  ---
@@ -139,17 +154,17 @@ Press `B` then select script path management to:
139
154
 
140
155
  ---
141
156
 
142
- ## Global Search & Config Mode
157
+ ## Search & Config Mode
143
158
 
144
- ### Global Search (`G`)
159
+ ### Search (`/`)
145
160
 
146
- Search file names or text inside every bookmarked directory.
161
+ Search file names or text under the current directory.
147
162
 
148
- - `Tab`: Switch between file names and content (literal, case insensitive)
163
+ - `Tab`: Switch between fuzzy file names (best matches first) and literal content (case insensitive)
149
164
  - Content search also reads `.pdf` (page), `.xlsx` (sheet/cell) and `.pptx` (slide)
150
165
  - `Up/Down` or `Ctrl+J/K or Ctrl+N/P`: Select a result | `Enter`: Go to the file in Files mode
151
- - `Ctrl+U`: Clear the query | `ESC`: Return to the previous mode
152
- - Exclude extensions (or `/name` directories and files) with `GLOBAL_SEARCH_EXCLUDED_EXTENSIONS` in `~/.config/rufio/config.rb`
166
+ - `Ctrl+U`: Clear the query | `ESC`: Return to Files mode
167
+ - Exclude extensions (or `/name` directories and files) with `SEARCH_EXCLUDED_EXTENSIONS` in `~/.config/rufio/config.rb` (the older `GLOBAL_SEARCH_EXCLUDED_EXTENSIONS` is still read)
153
168
 
154
169
  ### Config Mode (`C`)
155
170
 
@@ -162,7 +177,6 @@ and file operations as Files mode. Leaving the directory returns to Files mode.
162
177
 
163
178
  | Key | Action |
164
179
  |-----|--------|
165
- | `G` | Global search mode |
166
180
  | `C` | Config mode: open `~/.config/rufio/` |
167
181
  | `J` | Job mode |
168
182
  | `L` | Execution logs |
@@ -171,7 +185,7 @@ and file operations as Files mode. Leaving the directory returns to Files mode.
171
185
  | `q` | Quit rufio (with confirmation) |
172
186
  | `T` | Quit rufio and cd the shell to the current directory (requires `rufio --shell-init`) |
173
187
 
174
- In Files mode, `Tab` / `Shift+Tab` cycle bookmarks. In other modes, `Shift+Tab` switches to the previous mode.
188
+ In modes other than Files and Config, `Shift+Tab` switches to the previous mode.
175
189
 
176
190
  ### Help Menu
177
191
 
@@ -187,11 +201,11 @@ In Files mode, `Tab` / `Shift+Tab` cycle bookmarks. In other modes, `Shift+Tab`
187
201
 
188
202
  1. **Quick navigation**: Use `g` and `G` to jump to top/bottom
189
203
  2. **Bulk operations**: Select multiple files with `Space`, then use `m/c/x`
190
- 3. **Filter + Search**: Use `f` for real-time filtering, `s` for fuzzy search
204
+ 3. **Filter + Search**: Use `f` for real-time filtering, `/` to search the directory tree
191
205
  4. **Bookmarks**: Save frequently used directories with `b`, access with `1-9`
192
206
  5. **Rake tasks**: If your project has a Rakefile, use `:rake:` with Tab completion
193
207
  6. **Background jobs**: Long-running commands and ZIP jobs execute in background, view with `J`
194
- 7. **Global search**: Press `G` to search names or contents across all bookmarks
208
+ 7. **Search**: Press `/` to search names or contents under the current directory
195
209
 
196
210
  ---
197
211
 
data/info/keybindings.md CHANGED
@@ -24,9 +24,20 @@ Complete reference of all keyboard shortcuts in **rufio**.
24
24
  | `d` | Delete file or directory (with confirmation) |
25
25
  | `a` | Create new file |
26
26
  | `A` | Create new directory |
27
+ | `y` | Copy the path of the current file to the clipboard |
27
28
 
28
29
  `.zip` previews list the archive entries (size, method, modified time, name) without extracting them.
29
30
 
31
+ Image previews (`.png`, `.jpg`, `.bmp`) use the Kitty graphics protocol when the terminal supports it; the bundled native library decodes and scales the picture down to the pane first. Otherwise the format, size and dimensions are shown as text. `RUFIO_IMAGE_PREVIEW=0` disables images, `RUFIO_NATIVE_IMAGE=0` only the decoding (PNG is then sent as-is).
32
+
33
+ ### Preview of an image
34
+ - **+** / **-**: Zoom in 25% steps, up to 4x
35
+ - **0**: Fit the picture to the pane
36
+ - **h/j/k/l** or the **arrow keys**: Move around the picture while zoomed
37
+ - **y**: Copy the file path | **ESC**: Back to the file list
38
+
39
+ `.csv`, `.tsv`, `.tab`, `.xlsx`, `.xlsm` and `.ods` previews, and SQLite databases when the `sqlite3` command is installed, show the file as a grid: column letters with the header row, row numbers, a fixed header while scrolling, and a last line with the row/column counts, the detected encoding and any truncation. `TABLE_PREVIEW` in `config.rb` changes the limits (`max_bytes`, up to 4 MiB, `max_rows`, `max_columns`, `max_column_width`) and the `header`, `delimiter` and `encoding` handling.
40
+
30
41
  Text previews read at most the first 64 KiB. PDF bodies are not previewed, keeping file navigation responsive.
31
42
 
32
43
  ## File Selection
@@ -37,6 +48,7 @@ Text previews read at most the first 64 KiB. PDF bodies are not previewed, keepi
37
48
  | `m` | Move selected items to current directory |
38
49
  | `c` | Copy selected items to current directory |
39
50
  | `x` | Delete selected items |
51
+ | `y` | Copy every selected path to the clipboard (one per line) |
40
52
  | `z` | Extract selected `.zip` files (each into `<name>/`) / compress selected items into one `.zip` |
41
53
 
42
54
  ZIP extraction and compression run as background jobs. Check progress in Jobs mode (`J`).
@@ -46,10 +58,9 @@ ZIP extraction and compression run as background jobs. Check progress in Jobs mo
46
58
  | Key | Action |
47
59
  |-----|--------|
48
60
  | `f` | Enter filter mode (type to filter) |
49
- | `s` | Search file names with fzf |
50
- | `/` | Search file names with fzf (same as `s`) |
51
- | `F` | Search file contents with rga |
52
- | `G` | Global search: file names or contents across all bookmarks |
61
+ | `/` | Search under the current directory (file names or contents) |
62
+
63
+ `/` is the only search key, and what it searches depends on where you are: the file list searches the directory tree, a preview searches inside the file, and a table preview filters its rows. In the file list it opens the search screen, where you type to filter, **Tab** switches between fuzzy file names and literal contents, **Up/Down** or **Ctrl+J/K** select, **Enter** goes to the file and **ESC** returns.
53
64
 
54
65
  ## Bookmarks & Navigation
55
66
 
@@ -59,8 +70,6 @@ ZIP extraction and compression run as background jobs. Check progress in Jobs mo
59
70
  | `B` | Bookmark menu (view/add/remove/script paths) |
60
71
  | `0` | Jump to startup directory |
61
72
  | `1-9` | Jump to bookmark 1-9 |
62
- | `Tab` | Cycle to next bookmark (Files mode) |
63
- | `Shift+Tab` | Cycle to previous bookmark (Files mode) |
64
73
  | `z` | Navigate using zoxide history (when nothing is selected) |
65
74
 
66
75
  ## Modes & Tool Runtime
@@ -68,7 +77,6 @@ ZIP extraction and compression run as background jobs. Check progress in Jobs mo
68
77
  | Key | Action |
69
78
  |-----|--------|
70
79
  | `:` | Enter command mode |
71
- | `G` | Global search mode |
72
80
  | `C` | Config mode: open `~/.config/rufio/` |
73
81
  | `J` | Job mode (view background jobs) |
74
82
  | `L` | View execution logs |
@@ -82,10 +90,32 @@ ZIP extraction and compression run as background jobs. Check progress in Jobs mo
82
90
 
83
91
  ### Preview
84
92
  - **P**: Open fullscreen file preview (hides the file list)
93
+ - **y**: Copy the file path to the clipboard
85
94
  - **j/k**: Scroll preview
86
95
  - **Ctrl+D/U**: Page down/up
96
+ - **/**: Search inside the file. Type to jump to the first match, `Enter` keeps it, **n** / **N** move to the next / previous match (wrapping around), `ESC` clears the search. Matches are highlighted, the current one in a different colour
97
+ - **ESC**: Back to the file list (clears a search first)
98
+
99
+ ### Preview of a table (`.csv` / `.tsv` / `.tab` / `.xlsx` / `.xlsm` / `.ods` / SQLite)
100
+ - **h/j/k/l** or the **arrow keys**: Move the cell cursor. The grid scrolls, horizontally as well, to keep the cursor in view and the header row in place
101
+ - **Ctrl+D/U**: Move one screen of rows
102
+ - **g/}**: First / last row
103
+ - **0/$**: First / last column of the row
104
+ - **Space**: Select / unselect the column under the cursor. The selected columns' cells are marked, and the line under the file name lists them (`cols A,C`). Switching sheets clears the selection
105
+ - **y**: Copy the cell under the cursor to the clipboard (the raw value, including any newlines inside it). With columns selected, it copies the cursor row's selected columns instead, joined with commas as one CSV line (`apple,30`), in column order
106
+ - **Y**: Copy the whole row as one CSV line
107
+ - **[/]**: Previous / next sheet, for a workbook's sheets or a database's tables
108
+ - **/**: Filter the rows. `price > 100, name a%` means price over 100 and a name starting with `a`; a term without a column is searched in every column. `Enter` applies it, `ESC` clears it. A SQLite table is filtered with a read-only `SELECT ... WHERE` inside the database, so rows past the preview's row limit are found too
109
+ - **t**: Open the list of sheets or tables. `j`/`k` or the arrow keys move, `Ctrl+D/U` page, `g/}` jump to the first and last entry, `Enter` opens the selected one, `ESC` closes the list. `>` marks the sheet on screen. A single-sheet file has no list
110
+ - The line under the file name shows the cell address and the column name, e.g. `R3C2 price`, and the result of a copy
87
111
  - **ESC**: Back to the file list
88
112
 
113
+ Cell movement follows the `move_up` / `move_down` / `navigate_parent` / `navigate_enter` keybinds, so rebinding `hjkl` applies here too.
114
+
115
+ A `.csv` or `.tsv` is read up to 512 KiB, and only `max_rows` rows of it are parsed, so a wider limit costs no more parsing. Only the sheet being shown is read, so a workbook's other sheets and a database's other tables cost nothing until you switch to them. A SQLite database is recognised by the file's own signature, whatever its extension. A spreadsheet over 10 MiB, or one that cannot be read, falls back to the ZIP entry list.
116
+
117
+ Copying uses `pbcopy`, `clip`, `wl-copy`, `xclip` or `xsel` when one is available, and OSC 52 otherwise, which also works over SSH if the terminal supports it (in tmux, `set -g set-clipboard on`). `CLIPBOARD_COMMAND` in `config.rb` sets your own command, and `rufio -c` reports which one is used.
118
+
89
119
  ### Filter Mode
90
120
  - **Any character**: Add to filter query
91
121
  - **Backspace**: Remove last character
@@ -107,14 +137,16 @@ ZIP extraction and compression run as background jobs. Check progress in Jobs mo
107
137
  - `cd <path>` - Go to a directory (paste a path; a file path selects the file, `cd -` goes back, `Tab` completes directories)
108
138
  - `command` - Execute a built-in or plugin command
109
139
 
110
- ### Global Search (G)
111
- - **Type**: Filter results (literal, case insensitive)
140
+ ### Search (`/`) in the file list
141
+ - **Type**: Filter results (fuzzy for file names, literal and case insensitive for contents)
112
142
  - **Tab**: Switch between file names and content
113
143
  - **Up/Down** or **Ctrl+J/K or Ctrl+N/P**: Select a result
114
144
  - **Enter**: Go to the selected file in Files mode
115
145
  - **Ctrl+U**: Clear the query
116
- - **ESC**: Return to the previous mode
146
+ - **ESC**: Return to Files mode
147
+ - Only the current directory tree is searched; bookmarks are not
117
148
  - Content search also reads `.pdf`, `.xlsx` and `.pptx`
149
+ - `SEARCH_EXCLUDED_EXTENSIONS` in `config.rb` skips extensions, or `/name` directories and files
118
150
 
119
151
  ### Config Mode (C)
120
152
  - Same navigation, preview and file operations as Files mode
@@ -138,7 +170,7 @@ ZIP extraction and compression run as background jobs. Check progress in Jobs mo
138
170
 
139
171
  - **Vim users**: Navigation keys (`hjkl`) work exactly like Vim
140
172
  - **Selection**: Use `Space` to mark multiple files, then operate on all at once
141
- - **Quick access**: Number keys `1-9` and `Tab` provide instant access to bookmarks
173
+ - **Quick access**: Number keys `1-9` provide instant access to bookmarks
142
174
  - **Filtering**: Press `f` and start typing for real-time filtering
143
175
  - **Rake tasks**: Type `:rake:` then `Tab` to see available tasks
144
176
  - **Local scripts**: Scripts in the current directory are auto-detected with `@` prefix
data/info/welcome.md CHANGED
@@ -9,8 +9,8 @@ A TUI file manager that executes and coordinates tools and scripts from files.
9
9
  - **Tool Runtime** - Execute scripts and rake tasks from command mode
10
10
  - **Vim-like Keybindings** - Navigate with `j/k/h/l` keys
11
11
  - **Real-time Filtering** - Press `f` to filter files instantly
12
- - **Advanced Search** - Use `fzf` for file names and `rga` for content search
13
- - **Global Search** - Press `G` to search names or contents (including PDF/Excel/PowerPoint) across all bookmarks
12
+ - **One Search Key** - Press `/` to search: file names or contents (including PDF/Excel/PowerPoint) under the current directory, inside a preview, or the rows of a table
13
+ - **Grid & Image Previews** - View `.csv` / `.tsv` / `.xlsx` / `.ods` / SQLite as grids and `.png` / `.jpg` / `.bmp` in Kitty-compatible terminals
14
14
  - **ZIP Support** - Preview `.zip` contents, extract or compress selected items with `z`
15
15
  - **Bookmark Support** - Quick access to favorite directories
16
16
  - **Job Management** - Run commands in the background
@@ -25,12 +25,10 @@ Text previews read at most the first 64 KiB. PDF bodies are not previewed, keepi
25
25
  | `j/k` | Move down/up |
26
26
  | `h/l` | Go to parent / Enter directory |
27
27
  | `f` | Filter files |
28
- | `s` | Search with fzf |
28
+ | `/` | Search under the current directory |
29
29
  | `b` | Add bookmark |
30
30
  | `B` | Bookmark menu |
31
- | `Tab` | Next bookmark |
32
31
  | `z` | zoxide history / extract or compress selected items |
33
- | `G` | Global search across bookmarks |
34
32
  | `C` | Config mode |
35
33
  | `:` | Command mode |
36
34
  | `J` | Job mode |
@@ -39,7 +37,7 @@ Text previews read at most the first 64 KiB. PDF bodies are not previewed, keepi
39
37
  | `q` | Quit |
40
38
  | `T` | Quit and cd to the current directory |
41
39
 
42
- In G mode, use `Up` / `Down` or `Ctrl+J` / `Ctrl+K` to select the next / previous result and `Enter` to open it. Application cursor arrows and extended Ctrl-key sequences are supported, including on Ghostty.
40
+ In the search screen, use `Up` / `Down` or `Ctrl+J` / `Ctrl+K` to select the next / previous result and `Enter` to open it. Application cursor arrows and extended Ctrl-key sequences are supported, including on Ghostty.
43
41
 
44
42
  ## Command Mode
45
43
 
@@ -16,6 +16,13 @@ module Rufio
16
16
  @expires_at = nil
17
17
  end
18
18
 
19
+ # 即時操作の結果など、短い通知を出す(DISPLAY_DURATION 秒後に自動で消える)。
20
+ def notify(message, now: Time.now)
21
+ @message = message
22
+ @expires_at = now + DISPLAY_DURATION
23
+ true
24
+ end
25
+
19
26
  # 描画に関わる状態が変化した場合だけ true を返す。
20
27
  def update(executor, now: Time.now)
21
28
  changed = expire(now)
@@ -18,7 +18,6 @@ module Rufio
18
18
  @notification_manager = notification_manager
19
19
  @zoxide_integration = zoxide_integration
20
20
  @terminal_ui = nil
21
- @last_bookmark_idx = nil
22
21
  end
23
22
 
24
23
  def set_terminal_ui(terminal_ui)
@@ -133,8 +132,6 @@ module Rufio
133
132
  return false unless bookmark
134
133
  return false unless @bookmark_manager.path_exists?(bookmark)
135
134
 
136
- # Tab循環位置を更新(数字キー後の Tab が次の番号から続くように)
137
- @last_bookmark_idx = number - 1
138
135
  navigate_to_directory(bookmark[:path])
139
136
  end
140
137
 
@@ -150,22 +147,6 @@ module Rufio
150
147
  navigate_to_directory(start_dir)
151
148
  end
152
149
 
153
- # 次のブックマークに移動(Tabキー)
154
- # 現在のディレクトリがブックマーク内なら current_path を基準に次へ、
155
- # そうでない場合は @last_bookmark_idx から継続(ブックマーク外に出ても循環が止まらない)
156
- # 存在しないパスのブックマークはスキップする
157
- # @return [Integer, nil] 新しいブックマークインデックス、またはnil
158
- def goto_next_bookmark
159
- cycle_bookmark(1)
160
- end
161
-
162
- # 前のブックマークに移動(Shift+Tabキー)
163
- # 存在しないパスのブックマークはスキップする
164
- # @return [Integer, nil] 新しいブックマークインデックス、またはnil
165
- def goto_prev_bookmark
166
- cycle_bookmark(-1)
167
- end
168
-
169
150
  # ============================
170
151
  # zoxide 連携
171
152
  # ============================
@@ -304,32 +285,6 @@ module Rufio
304
285
 
305
286
  private
306
287
 
307
- def cycle_bookmark(step)
308
- bookmarks = @bookmark_manager.list
309
- return nil unless bookmarks&.any?
310
-
311
- len = bookmarks.length
312
- current_path = @directory_listing.current_path
313
- current_position = bookmarks.find_index { |bm| bm[:path] == current_path }
314
- start_idx = if current_position
315
- (current_position + step + len) % len
316
- elsif @last_bookmark_idx
317
- (@last_bookmark_idx + step + len) % len
318
- else
319
- step > 0 ? 0 : len - 1
320
- end
321
-
322
- len.times do |i|
323
- idx = (start_idx + (i * step) + len) % len
324
- next unless Dir.exist?(bookmarks[idx][:path])
325
-
326
- @last_bookmark_idx = idx
327
- navigate_to_directory(bookmarks[idx][:path])
328
- return @last_bookmark_idx
329
- end
330
- nil
331
- end
332
-
333
288
  def show_notification(title, _message, type)
334
289
  return unless @notification_manager
335
290
 
@@ -0,0 +1,162 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'base64'
4
+ require 'rbconfig'
5
+ require_relative 'config_loader'
6
+ require_relative 'command_locator'
7
+
8
+ module Rufio
9
+ # クリップボードへのコピー。
10
+ #
11
+ # OS のコマンド(pbcopy / clip / wl-copy / xclip / xsel)を優先し、見つからなければ
12
+ # OSC 52 で端末に渡す。OSC 52 は SSH 越しでも届く代わりに、端末が対応しているかを
13
+ # 知る方法がない(成否が返らない)ため、どの手段を使ったかを呼び出し側で表示する。
14
+ #
15
+ # コマンドはシェルを経由せず argv で起動する(SECURITY.md の方針)。
16
+ module Clipboard
17
+ # コピーできる最大サイズ
18
+ MAX_BYTES = 100 * 1024
19
+ # OSC 52 で多くの端末が受け取れる上限の目安
20
+ OSC52_MAX_BYTES = 74_994
21
+ # コピー時に落とす末尾の改行
22
+ TRAILING_NEWLINES = /[\r\n]+\z/.freeze
23
+ # 改行とタブ以外の制御文字。セルの値としては意味を持たない一方、貼り付け先の端末を
24
+ # 操作しうる(ブラケットペーストが無効な端末では ESC がそのまま解釈される)
25
+ UNSAFE_CONTROL_CHARS = /[[:cntrl:]&&[^\n\t]]+/.freeze
26
+
27
+ Candidate = Struct.new(:name, :argv, keyword_init: true)
28
+
29
+ class << self
30
+ # @param text [String] コピーする文字列
31
+ # @return [Symbol, false] 使った手段(:pbcopy / :xclip / :osc52 ...)、失敗なら false
32
+ def copy(text, out: $stdout)
33
+ return false if text.nil?
34
+
35
+ # 末尾の改行は、シェルに貼り付けた瞬間にそのまま実行される原因になるため落とす。
36
+ # 途中の改行は値そのものなので残す(複数行だと分かるよう呼び出し側が件数を出す)。
37
+ # 改行・タブ以外の制御文字は、貼り付け先の端末を操作しうるので空白に置き換える
38
+ payload = sanitize(text.to_s)
39
+ return false if payload.empty? || payload.bytesize > MAX_BYTES
40
+
41
+ candidate = command_candidate
42
+ return candidate.name if candidate && run_command(candidate.argv, payload)
43
+
44
+ osc52(payload, out: out) ? :osc52 : false
45
+ end
46
+
47
+ # rufio -c(ヘルスチェック)用。使えそうな手段の名前
48
+ # @return [Symbol] コマンドが見つからなければ :osc52
49
+ def available_method
50
+ command_candidate&.name || :osc52
51
+ end
52
+
53
+ # 見つかったコマンドの argv(ヘルスチェックの表示用)
54
+ def available_command
55
+ command_candidate&.argv
56
+ end
57
+
58
+ # 設定や環境変数を読み直す(テスト用)
59
+ def reset!
60
+ @command_candidate = nil
61
+ @resolved = false
62
+ CommandLocator.reset!
63
+ end
64
+
65
+ private
66
+
67
+ def sanitize(text)
68
+ trimmed = text.sub(TRAILING_NEWLINES, '')
69
+ trimmed.match?(UNSAFE_CONTROL_CHARS) ? trimmed.gsub(UNSAFE_CONTROL_CHARS, ' ') : trimmed
70
+ end
71
+
72
+ def command_candidate
73
+ return @command_candidate if @resolved
74
+
75
+ @resolved = true
76
+ @command_candidate = candidates.find { |candidate| command_available?(candidate.argv.first) }
77
+ end
78
+
79
+ def candidates
80
+ [configured_candidate, *platform_candidates].compact
81
+ end
82
+
83
+ # config.rb の CLIPBOARD_COMMAND(文字列または argv 配列)
84
+ def configured_candidate
85
+ value = ConfigLoader.clipboard_command
86
+ return nil if value.nil?
87
+
88
+ argv = (value.is_a?(Array) ? value : [value]).map(&:to_s).reject(&:empty?)
89
+ return nil if argv.empty?
90
+
91
+ Candidate.new(name: :configured, argv: argv)
92
+ end
93
+
94
+ def platform_candidates
95
+ case RbConfig::CONFIG['host_os']
96
+ when /darwin/
97
+ [Candidate.new(name: :pbcopy, argv: ['pbcopy'])]
98
+ when /mswin|mingw|cygwin/
99
+ [
100
+ Candidate.new(name: :clip, argv: ['clip']),
101
+ Candidate.new(name: :set_clipboard,
102
+ argv: ['powershell', '-NoProfile', '-Command', '$input | Set-Clipboard'])
103
+ ]
104
+ else
105
+ unix_candidates
106
+ end
107
+ end
108
+
109
+ # Wayland / X11 のセッションがあるときだけコマンドを試す。
110
+ # SSH 越し(DISPLAY なし)では OSC 52 に任せる。
111
+ def unix_candidates
112
+ list = []
113
+ list << Candidate.new(name: :wl_copy, argv: ['wl-copy']) if env?('WAYLAND_DISPLAY')
114
+ if env?('DISPLAY')
115
+ list << Candidate.new(name: :xclip, argv: ['xclip', '-selection', 'clipboard'])
116
+ list << Candidate.new(name: :xsel, argv: ['xsel', '--clipboard', '--input'])
117
+ end
118
+ list
119
+ end
120
+
121
+ def env?(name)
122
+ value = ENV[name]
123
+ !value.nil? && !value.empty?
124
+ end
125
+
126
+ def command_available?(name)
127
+ CommandLocator.available?(name)
128
+ end
129
+
130
+ def run_command(argv, text)
131
+ IO.popen(argv, 'w') { |io| io.write(text) }
132
+ status = Process.last_status
133
+ status.nil? || status.success?
134
+ rescue SystemCallError, IOError
135
+ false
136
+ end
137
+
138
+ # OSC 52。tmux / screen の中では DCS パススルーで包む必要がある。
139
+ def osc52(text, out: $stdout)
140
+ sequence = "\e]52;c;#{Base64.strict_encode64(text)}\a"
141
+ return false if sequence.bytesize > OSC52_MAX_BYTES
142
+
143
+ out.write(wrap_for_multiplexer(sequence))
144
+ out.flush
145
+ true
146
+ rescue SystemCallError, IOError
147
+ false
148
+ end
149
+
150
+ def wrap_for_multiplexer(sequence)
151
+ if env?('TMUX')
152
+ # tmux 側は set-clipboard on が必要
153
+ "\ePtmux;#{sequence.gsub("\e", "\e\e")}\e\\"
154
+ elsif ENV['TERM'].to_s.start_with?('screen')
155
+ "\eP#{sequence.gsub("\e", "\e\e")}\e\\"
156
+ else
157
+ sequence
158
+ end
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rbconfig'
4
+
5
+ module Rufio
6
+ # PATH 上にコマンドがあるかを調べる。
7
+ # which を起動しないので、キー入力ごとに呼ばれても負荷にならず、which が無い
8
+ # Windows でも動く(PATHEXT を見る)。
9
+ module CommandLocator
10
+ WINDOWS_DEFAULT_PATHEXT = '.COM;.EXE;.BAT;.CMD'
11
+
12
+ class << self
13
+ def available?(name)
14
+ cache.fetch(name) { cache[name] = locate(name) }
15
+ end
16
+
17
+ def reset!
18
+ @cache = {}
19
+ end
20
+
21
+ private
22
+
23
+ def cache
24
+ @cache ||= {}
25
+ end
26
+
27
+ def locate(name)
28
+ return false if name.nil? || name.to_s.empty?
29
+ return executable?(name) if name.to_s.include?(File::SEPARATOR)
30
+
31
+ ENV.fetch('PATH', '').split(File::PATH_SEPARATOR).any? do |dir|
32
+ next false if dir.empty?
33
+
34
+ extensions.any? { |ext| executable?(File.join(dir, "#{name}#{ext}")) }
35
+ end
36
+ end
37
+
38
+ def extensions
39
+ return [''] unless RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
40
+
41
+ (ENV['PATHEXT'] || WINDOWS_DEFAULT_PATHEXT).split(';')
42
+ end
43
+
44
+ def executable?(path)
45
+ File.executable?(path) && !File.directory?(path)
46
+ end
47
+ end
48
+ end
49
+ end
data/lib/rufio/config.rb CHANGED
@@ -34,13 +34,13 @@ module Rufio
34
34
  'file.cannot_preview' => 'Cannot preview',
35
35
  'file.encoding_error' => 'Character encoding error - cannot read file',
36
36
  'file.invalid_archive' => 'Invalid ZIP archive',
37
+ 'file.not_parsed_as_table' => 'not parsed as table',
37
38
  'file.preview_error' => 'Preview error',
38
39
  'file.error_prefix' => 'Error',
39
40
 
40
41
  # Keybind messages
41
42
  'keybind.invalid_key' => 'invalid key',
42
43
  'keybind.search_text' => 'Search text: ',
43
- 'keybind.no_matches' => 'No matches found.',
44
44
  'keybind.press_any_key' => 'Press any key to continue...',
45
45
  'keybind.input_filename' => 'Enter filename: ',
46
46
  'keybind.input_dirname' => 'Enter directory name: ',
@@ -63,10 +63,14 @@ module Rufio
63
63
  'health.title' => 'rufio Health Check',
64
64
  'health.ruby_version' => 'Ruby version',
65
65
  'health.required_gems' => 'Required gems',
66
- 'health.fzf' => 'fzf (file search)',
67
- 'health.rga' => 'rga (content search)',
66
+ 'health.sqlite3' => 'sqlite3 (SQLite preview)',
68
67
  'health.zoxide' => 'zoxide (directory history)',
69
68
  'health.bat' => 'bat (syntax highlight)',
69
+ 'health.clipboard' => 'Clipboard (y to copy)',
70
+ 'health.clipboard_osc52' => 'OSC 52 (no clipboard command found)',
71
+ 'health.clipboard_hint' => 'Install pbcopy, wl-copy, xclip or xsel for a local clipboard, ' \
72
+ 'or set CLIPBOARD_COMMAND. Over SSH, OSC 52 needs terminal support ' \
73
+ '(in tmux also set-clipboard on)',
70
74
  'health.file_opener' => 'System file opener',
71
75
  'health.summary' => 'Summary:',
72
76
  'health.ok' => 'OK',
@@ -87,7 +91,6 @@ module Rufio
87
91
  'health.install_brew' => 'Install: brew install',
88
92
  'health.install_apt' => 'Install: apt install',
89
93
  'health.install_guide' => 'Install: Check the installation guide for your platform',
90
- 'health.rga_releases' => 'Install: https://github.com/phiresky/ripgrep-all/releases',
91
94
  'health.ruby_upgrade_needed' => 'Please upgrade Ruby to version 2.7.0 or higher'
92
95
  }.freeze
93
96