innards 0.3.0

Inline terminal tools for Rust symbol navigation, editing, and paging
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# innards

Small "inline" terminal tools for jumping around source code and editing files without
clearing the shell above them.

On account of agents I spend most of my time in a terminal window these days
(and often also remote over SSH) and I missed some of the conveniences of an IDE...
but wanted something quick and nimble that didn't break flow in the shell.

These little utilities let you drop in and out of navigation and editing and
viewing files but keep what you were working on visible and integrate better into a
shell oriented workflow.

In particular: things like writing `git` commit messages, doing quick edits to source files,
finding the location of some function or symbol, doing interactive rebases, or quick
document updates.

Basically: Quick to start, and get out of your way quickly after.

## Demos

`inmacs` as an inline editor:

<p align="center">
  <img src="inmacs-screencast.gif" width="845" alt="inmacs inline editor demo">
</p>

`navsplat` as an inline symbol picker:

<p align="center">
  <img src="navsplat-screencast.gif" width="845" alt="navsplat inline symbol picker demo">
</p>

`inbase` as an inline interactive rebase sequence editor:

<p align="center">
  <img src="inbase-screencast.gif" width="845" alt="inbase inline interactive rebase demo">
</p>

`inlog` as an inline Git log browser:

<p align="center">
  <img src="inlog-screencast.gif" width="845" alt="inlog inline Git log browser demo">
</p>

## Binaries

- `navsplat`: rust-analyzer-backed Rust workspace symbol picker.
- `inmacs`: inline editor with Emacs-like navigation and editing keys.
- `inpage`: read-only inline pager with the same movement/search surface as
  `inmacs`.
- `inbase`: inline Git interactive rebase sequence editor.
- `inlog`: inline Git log browser.

All five use ratatui with an inline terminal viewport, so they open below the
current prompt instead of taking over the whole screen.

## Build

```sh
cargo build --release --bins
```

The binaries will be under `target/release/`.

Build a Debian package with `cargo-deb`:

```sh
cargo install cargo-deb
cargo deb
```

The `.deb` will be written under `target/debian/`.

## Install

Install from a local checkout:

```sh
cargo install --path .
```

Install directly from git:

```sh
cargo install innards
# or
cargo install --git https://github.com/rdaum/innards.git
```

`cargo install` places the binaries in Cargo's bin directory, usually
`~/.cargo/bin`. Make sure that directory is on `PATH`.

## Requirements

`navsplat` starts `rust-analyzer` and talks to it over LSP, so `rust-analyzer`
must be on `PATH`.

`navsplat` opens selections with `$VISUAL`, then `$EDITOR`, then `vi` if neither
environment variable is set. It invokes the editor as:

```sh
$EDITOR +LINE FILE
```

Clipboard copy tries `wl-copy`, `xclip`, `xsel`, `pbcopy`, then OSC 52.

## navsplat

Run the interactive picker from inside a Rust project:

```sh
navsplat
```

Start with an initial query:

```sh
navsplat pick '#main'
```

Use a specific workspace root or editor:

```sh
navsplat --root ~/src/my-crate --editor 'vim' pick HashMap
```

Print matches without opening the TUI:

```sh
navsplat symbols '#main'
```

Options:

```text
--root PATH       Workspace root. Defaults to the nearest Cargo.toml or .git.
--editor CMD      Editor command. Defaults to $VISUAL, $EDITOR, then vi.
--height ROWS     Inline picker height. Defaults to 20.
```

Picker keys:

```text
Enter             Open the selected symbol, or promote a selected side-pane hit
Esc, Ctrl-C       Quit
q                 Quit when the search input is empty
Up/Down           Move selection
Ctrl-P/Ctrl-N     Move selection
PageUp/PageDown   Move by larger steps
Shift-Up/Down     Scroll the preview pane
Tab               Switch focus between symbols and the side pane
Alt-R             Show references
Alt-C             Show callers
Alt-E             Show callees
Alt-S             Return the right pane to source preview mode
Backspace         Pop back after promoting a side-pane hit
Alt-Y             Copy the selected location
```

The preview is centered around the selected symbol when possible. References,
callers, and callees are loaded lazily for the current selection.

## inmacs

Open a file in the inline editor:

```sh
inmacs src/lib.rs
```

Open at a line:

```sh
inmacs +120 src/lib.rs
inmacs --line 120 src/lib.rs
```

Set the inline viewport height:

```sh
inmacs --height 18 src/lib.rs
```

Core keys:

```text
Ctrl-X Ctrl-S     Save
Ctrl-X Ctrl-C     Quit
Ctrl-X 1          Expand to the full terminal height
Ctrl-X 0          Restore the previous inline height
Ctrl-S            Incremental search forward
Ctrl-R            Incremental search backward
Ctrl-S/Ctrl-R     Repeat search while searching
Enter             Finish search while searching
Esc, Ctrl-G       Cancel search while searching
Ctrl-G            Cancel active mark outside search
Ctrl-A/Ctrl-E     Start/end of line
Ctrl-B/Ctrl-F     Character left/right
Alt-B/Alt-F       Word left/right
Alt-Q             Fill/reflow the current paragraph
Ctrl-Left/Right   Word left/right
Ctrl-P/Ctrl-N     Line up/down
Alt-V/Ctrl-V      Page up/down
PageUp/PageDown   Page up/down
Alt-Up/Down       Shrink/grow the inline viewport
Ctrl-Space        Set or clear mark
Ctrl-W            Kill active region
Alt-W             Copy active region
Ctrl-Y            Yank
Ctrl-K            Kill to end of line
Ctrl-D/Delete     Delete character
Backspace         Delete backward
Ctrl-/ Ctrl-_     Undo
Ctrl-7            Undo
Ctrl-?            Redo, where the terminal reports it distinctly
```

When editing Git commit message files such as `COMMIT_EDITMSG`, `inmacs`
uses commit-message rules: 50 columns for the subject, 72 columns for body
fill and auto-wrap, a required blank line before the body, and ignored `#`
comment lines.

`inmacs` uses `ropey` internally for text storage and `syntect` for syntax
highlighting.

## inpage

Open a read-only inline pager:

```sh
inpage src/lib.rs
inpage +120 src/lib.rs
```

`inpage` accepts the same `--height`, `--line`, and `+LINE` arguments as
`inmacs`. Editing keys are disabled, but movement and search keys are shared.
When `inpage` exits, it leaves the final page content in the terminal without
the inline borders.

Additional pager quit keys:

```text
Esc
q
```

## inbase

Use `inbase` as Git's interactive rebase sequence editor:

```sh
git config --global sequence.editor inbase
# or
GIT_SEQUENCE_EDITOR=inbase git rebase -i HEAD~8
```

`inbase` edits the rebase todo file that Git passes to `$GIT_SEQUENCE_EDITOR`.
It writes the todo file and exits successfully when saved; abort exits non-zero
without writing.

Set the inline viewport height:

```sh
inbase --height 18 .git/rebase-merge/git-rebase-todo
```

Rebase keys:

```text
Ctrl-X Ctrl-S     Save and continue the rebase
Ctrl-X Ctrl-C     Prompt to save, abort, or cancel
s/a/c             Save, abort, or cancel while the quit prompt is open
Ctrl-P/Ctrl-N     Move selection up/down
Up/Down           Move selection up/down
Alt-P/Alt-N       Move selected todo line up/down
Alt-V/Ctrl-V      Page up/down
PageUp/PageDown   Page up/down
p                 Pick
r                 Reword
e                 Edit
s                 Squash
f                 Fixup
d                 Drop
x                 Exec, for existing exec lines only
```

## inlog

Browse Git history in an inline log viewer:

```sh
inlog
inlog -- --author ryan --since 2.weeks
inlog -- origin/main..HEAD -- src/inline_text.rs
```

`inlog` passes normal `git log` filters, revisions, paths, and sorting options
through to Git, but does not support `--graph`. If no max-count option is
provided, it loads the most recent 500 commits. When `inlog` exits, it collapses
the inline viewport and prints a compact highlighted summary for the selected
commit with the subject capped at 50 characters.

Set the inline viewport height:

```sh
inlog --height 24 -- -n 100
```

Log keys:

```text
Ctrl-S            Incremental search forward
Ctrl-R            Incremental search backward
Enter             Select commit, copy SHA, and quit; finish search while searching
Esc, Ctrl-G       Cancel search while searching
Ctrl-P/Ctrl-N     Move selection up/down
Up/Down           Move selection up/down
Alt-V/Ctrl-V      Page up/down
PageUp/PageDown   Page up/down
Alt-Up/Alt-Down   Shrink/grow the inline viewport
Ctrl-X 1          Expand to the full terminal height
Ctrl-X 0          Restore the previous inline height
/                 Expand/collapse the selected commit message
Alt-Y             Copy the selected full SHA
q, Esc            Quit
Ctrl-X Ctrl-C     Quit
```

## Configuration

Innards reads TOML configuration from:

```text
$XDG_CONFIG_HOME/innards/config.toml
```

If `XDG_CONFIG_HOME` is not set, it falls back to:

```text
~/.config/innards/config.toml
```

Example:

```toml
[inmacs]
fill_column = 100

[keybindings.inline]
fill_paragraph = "alt-q"
fullscreen = "ctrl-x 1"
restore_inline = "ctrl-x 0"
save = "ctrl-x ctrl-s"
quit = "ctrl-x ctrl-c"
search_forward = "ctrl-s"
search_reverse = "ctrl-r"
page_up = ["alt-v", "pageup"]
page_down = ["ctrl-v", "pagedown"]

[keybindings.navsplat]
open = "enter"
quit = ["esc", "ctrl-c"]
toggle_focus = "tab"
references = "alt-r"
callers = "alt-c"
callees = "alt-e"
source = "alt-s"
copy = "alt-y"

[keybindings.rebase]
save = "ctrl-x ctrl-s"
quit = "ctrl-x ctrl-c"
select_prev = ["ctrl-p", "up"]
select_next = ["ctrl-n", "down"]
move_up = "alt-p"
move_down = "alt-n"
pick = "p"
reword = "r"
edit = "e"
squash = "s"
fixup = "f"
drop = "d"

[keybindings.log]
quit = ["ctrl-x ctrl-c", "esc", "q"]
search_forward = "ctrl-s"
search_reverse = "ctrl-r"
select_prev = ["ctrl-p", "up"]
select_next = ["ctrl-n", "down"]
shrink_height = "alt-up"
grow_height = "alt-down"
fullscreen = "ctrl-x 1"
restore_inline = "ctrl-x 0"
toggle_expand = "/"
copy = "alt-y"
accept = "enter"
```

Configured action bindings replace the built-in bindings for that action.
Unmentioned actions keep their defaults. Key names are case-insensitive and can
use modifiers such as `ctrl-`, `alt-`, and `shift-`. Multi-key sequences are
written with spaces, for example `ctrl-x ctrl-s`.

Inline actions shared by `inmacs` and `inpage`:

```text
quit, save, search_forward, search_reverse, cancel_search, finish_search,
cancel_mark, set_mark, undo, redo, line_start, line_end, word_left,
word_right, char_left, char_right, line_up, line_down, page_up, page_down,
copy_region, kill_region, kill_to_eol, yank, delete_char, backspace,
insert_newline, insert_tab, shrink_height, grow_height, fullscreen,
restore_inline, fill_paragraph, quit_view
```

`navsplat` actions:

```text
quit, quit_if_empty, open, pop, toggle_focus, references, callers, callees,
source, copy, select_prev, select_next, preview_up, preview_down, page_up,
page_down, delete_next_char
```

`inbase` actions:

```text
save, quit, select_prev, select_next, move_up, move_down, page_up, page_down,
pick, reword, edit, squash, fixup, drop, exec, prompt_save, prompt_abort,
prompt_cancel
```

`inlog` actions:

```text
quit, search_forward, search_reverse, cancel_search, finish_search,
search_backspace, select_prev, select_next, page_up, page_down, shrink_height,
grow_height, fullscreen, restore_inline, toggle_expand, copy, accept
```

## Development

Useful checks:

```sh
cargo fmt
cargo check --bins
cargo test --lib
cargo build --bins
```

GitHub Actions runs formatting, Clippy, tests, and release binary builds on
pushes to `main` and pull requests. Pushing a `v*` tag builds the Debian package
and uploads it to the corresponding GitHub Release; the Debian package workflow
can also be run manually from the Actions tab.

## License

`innards` is licensed under GPL-3.0-only. See `LICENSE`.