Your terminal manipulation/navigation setups

30 points by nocoffei 5 days ago on lobsters | 21 comments

geocar | 5 days ago

The most irritating aspect to me is editing a previous command,

Friend, let me tell you about the fc command. fc -l lists the last few commands. fc and a number edits that command in your favorite $EDITOR and then when you save/exit it runs it!

dtgriscom | 5 days ago

What does fc stand for? Or, how do I remember to use fc when it would be useful?

novedevo | 5 days ago

From man fc (emphasis mine):

In the KornShell, the alias r (``re-do'') is preset to fc -e - (equivalent to the POSIX fc -s). This is probably an easier command name to remember than fc (``fix command''), but it does not meet the Utility Syntax Guidelines. Renaming fc to hist or redo was considered, but since this description closely matches historical KornShell practice already, such a renaming was seen as gratuitous. Users are free to create aliases whenever odd historical names such as fc, awk, cat, grep, or yacc are standardized by POSIX.

geocar | 5 days ago

I remember when I fucked up the last command and I need to fix that command.

I don't know if that sort of thing helps you, but that's how I remember it anyway.

ashwinsundar | 5 days ago

This is a good one!

emallson | 5 days ago

When writing a terminal command, things can range from easy to brutal. Talon has a lot of built in terminal commands available, but composing complex commands still requires a great deal of typing. The most irritating aspect to me is editing a previous command, which consists of either holding (Ctrl+) an arrow key and waiting until I hit the right character, often overshooting, and then having to go back the opposite direction with the arrow keys again, OR moving with my mouse and clicking on the correct position.

is the problem the shell/terminal itself lacking editor a11y features? or the syntax/structure of the shell commands? if it is an editor problem, does your shell support "open command in editor"? i know fish and bash (via C-x C-e by default) do, which might let you take greater advantage of your other tools.

willhbr | 5 days ago

For scrollback I use tmux, so I can have that bound to an easy to reach key (C-o) and then use standard vim-style bindings (C-u/d) to go up and down or search.

For command line editing I'm a big fan of Zsh vim mode. I use w/b and f to jump around, and I can delete/yank/paste text in a command. I should probably set up the thing to open the command in $EDITOR but I don't find I want to very often.

Ditto, I use tmux's scrollback and copy/paste. What a godsend. Keyboard-driven text selection is the main benefit for me, but I also like that it keeps a history of copies (accessed via tmux list-buffer or tmux choose-buffer), unlike the OS clipboard manager. Gotta remember to clear secrets though with tmux delete-buffer.

k749gtnc9l3w | 4 days ago

With pipe-pane (and maybe capture-pane if you really need to copy from scrollback, not to tee correctly from the beginning) some secrets can never even enter the buffer history!

willhbr | 4 days ago

I was a clipboard manager skeptic for a long time, but have now converted. If you like clipboard history in tmux, you should get something for your system (I use Pastebot on MacOS).

epilys | 5 days ago

I am fairly convinced there is no true voice first terminal experience-- this is something I am hoping to change

I've written a terminal e-mail client. If I want to make my terminal app usable by voice, what assistive software stack should I use for development? I am aware of things like AccessKit but that's geared to graphical user interfaces.

Since my client is a library with a terminal front end, I do not even need to retrofit this kind of accessibility, I can just write a new front end.

Irene | 5 days ago

I think it would be a worst-case for screen readers due to excessive redraws, but as far as copy-paste goes I use tmux, which has its own internal clipboard that is accessed through its key bindings. those bindings are also changeable.

k749gtnc9l3w | 5 days ago

If we are talking tmux, there is also tmux capture-pane -J -p -S -999 (basically output the last 999 lines of scrollback, ignoring linewrapping; then this goes into an editor)

As the question is about input accessibility more than output accessibility, I think tmux might be in fact useful.

pbsds | 5 days ago

I scroll the view using keybinds that are default in many terminal emulators, namely ctrl+shift+up, ctrl+shift+down, shift+pgup, and shift+pgdown. It seems also that ghostty has the ability to configure keybinds to adjust the selection, which may be of interest to you

stringy | 4 days ago

I empathize deeply with your assessment that "there must be better ways", but I haven't found any of the usual answers very compelling.

Like others have noted, shells like bash and zsh do have reasonable shortcuts for editing if you don't mind emacs or vi keybindings, but even then the copy/paste situation is sort of abysmal if you use something crazy like multiple applications for your work. Falling back to the "open current cmdline as a buffer in $EDITOR" can help but is sort of jarring and clunky to be doing constantly. Fuzzy-find history search also helps, but only between multiple terminals, not between terminals and anything else.

Add in wanting to work remotely, and you're stuck with screen or tmux which as hard as I try I cannot work efficiently in. They also add more opportunities for TERM weirdness and (especially with visual command-line utilities) can add some latency. They also add another kind of buffer/window to organize, with a whole new set of keybindings.

In light of all that, I've just moved to Neovim as my terminal multiplexer, and in particular I run an instance headless as a lingering systemd user service on any hosts I work on remotely. I attach and detach from these with a script over ssh using Neovide. This limits the terminal emulation compatibility issue to just Neovim, with no nesting of virtual terminals.

Other benefits, which I think you're interested in more directly:

  • With the vi-edit mode set up for my terminal (with a different escape sequence to not conflict with Neovim) this means I get one unified set of motions and commands for editing/selecting/copying/pasting/... in basically every context I care about while working. Terminal scrollback is just navigating a text buffer, and I have shortcuts to jump between shell prompts to navigate even more naturally.
  • I use the leap plugin constantly, which also transparently works in terminal buffers. It removes the need for the fine-motor-skill mouse movements for highlighting text: you type the letters you're looking at (and a disambiguating label that appears) and your cursor is where you're looking. Vim's usual selection motions work from there, or you can use leap to define the end of your selection, too.
  • A side-effect of my terminals all being in my editor is that it is easy to e.g. fuzzy-search my open buffers and paste the file path of whichever I'm interested in into a shell command-line; I have a binding for the most common case of wanting to paste the path of the "previous" buffer and use it pretty often.
  • This also means the clipboard on the machine I'm actually typing on (the non-emulated "terminal" machine, I suppose) is transparently visible to (and so shared by) every terminal and every editor window I have on every machine I connect to, as well as all the native apps on my local desktop. This alone is what drove me to this setup. Having copy and paste actually just work in the tools I use without ever touching a mouse has been life altering.

I might be missing some things, but that has been my general approach to the exact problem you're describing: stuff everything in headless Neovim instances, connect with Neovide. Maybe surprisingly, everything "just works".

(Full disclosure: There is a bug where I sometimes have to force things be re-drawn after reconnecting, and I haven't had a chance to look into it. It is a minor annoyance, and I'm sure one that either Neovim or Neovide will resolve at some point, even if I don't get the time to look into it myself soon.)

i've been hacking on my own terminal multiplexer: an infinite canvas terminal multiplexer that uses libghostty-vt for terminals, and iroh to connect to remote daemons.

i have been posting about it on bsky: https://bsky.app/profile/did:plc:qfpnj4og54vl56wngdriaxug/post/3mzgp5uew222e

work in progress codebase: https://tangled.org/oppi.li/tarp

adrien | 5 days ago

When writing a terminal command, things can range from easy to brutal. Talon has a lot of built in terminal commands available, but composing complex commands still requires a great deal of typing. The most irritating aspect to me is editing a previous command, which consists of either holding (Ctrl+) an arrow key and waiting until I hit the right character, often overshooting, and then having to go back the opposite direction with the arrow keys again, OR moving with my mouse and clicking on the correct position.

I use zsh in vi mode and it's pretty capable these days. This means that going back in history can be done with j/k and then it's possible to edit the command-line as in vi(m), including typical movements (using f/F/t/T to aim for a character, b/B/w/W/e/E for word movement), visual selection, adding newlines but also copy-pasting across history entries.

This is probably not restricted to zsh in vi mode but it's an implementation that I find really satisfactory in practice.

And now I've finally added the ability to edit the current command-line in my editor using zsh' edit-command-line module for the rare cases that get too complex for the editor in zsh (and at that point, it means I should really save my stuff in a dedicated file).

vakili | 5 days ago

Echoing some of the earlier comments, here is my setup with WezTerm terminal and fish shell:

  • Scrolling: WezTerm's Copy Mode (Ctrl+Shift+X), to use Vim motions or PgUp/PgDown to navigate scrollback and select text.

  • Editing terminal commands: readline-style shortcuts and Alt+E for fish’s edit_command_buffer, which opens the current command line in my preferred editor.

  • Reusing command arguments: bash's Alt+. shortcut inserts the last argument of the previous command. Pressing it repeatedly cycles through earlier commands. There are shortcuts for other arguments too.

  • Copying text: WezTerm's Quick Select Mode for copying strings matching certain (configurable) patterns.

    You might also look into keyboard-driven web browsers. I am a happy user of qutebrowser. There are also browser extensions (tridactyl?).

akavel | 5 days ago

Disclaimer: I don't have RSI, don't know much about voice controlled setups (though I remember some video with weird syllables - I managed to google up something by Tavis Rudd, though I'm not 100% sure it was that one), and don't know details about your condition. Thus can only throw around a few thoughts that come to me as possibly relevant or at least potential path to explore. Please disregard if useless to you.

For one, personally (again, not having RSI), I use an Apple-made touchpad, with my left hand. IIRC it works fine over bluetooth with any kind of machine with Bluetooth, not only Macs, though my work machines are Macs for quite a while so I may be misremembering. I bought it used, specifically to avoid creeping discomfort from using a mouse in my right hand. It seems to have helped in a major way, for me.

Second, for tweaking a command line and rerunning it a bunch of times in a loop, I developed a small helper app called Ultimate Plumber, or just up, though I'm not sure it'll work well with voice control. It may also be buggy or frustrating in various ways, I have trouble maintaining it, sorry. At least it's a very small codebase, FWIW, so you can maybe try forking.

Third, AFAIU, the author of the ghostty terminal also published a library, IIRC libghostty, that aims to make writing terminals easier. Maybe you could try coding something for yourself in it... though I'm fully aware it'd probably be a major time sink that you might not have time for especially now.

Good luck, regardless.

reverendpaco | 5 days ago

I've been interested in the svalboard... What do you think of it? Had you tried ergo keyboards before?

trenchant | 4 days ago

My terminal interaction has fallen from being a vim expert to using three inputs. I hold right-cmd to voice dictate. I press enter to send. And I two finger scroll the touchpad to view LLM output. I rarely read the code anymore. I use option-arrows to edit within a line when I feel like typing old school, but I imagine even this could be replaced with a local app accepting voice cmds describing the edit I'd like to make to the current line. Don't be afraid to fork your terminal's codebase.