Tech News
← Back to articles

I Use My Terminal

read original related products more articles

this is a whole blog post because it is "outside the overton window"; it usually takes at least a video before people even understand the thing i am trying to describe. so, here's the video:

the steps here that tend to surprise people are , , and . when i say "surprise" i don't just mean that people are surprised that i've set this up, but they are surprised this is possible at all.

here's what happens in that video:

I start with Windows Terminal open on my laptop. I hit ctrl-shift-5 , which opens a new terminal tab which ssh 's to my home desktop and immediately launches tmux. tmux launches my default shell, zsh . zsh shows a prompt, while loading the full config asynchronously i use zoxide to fuzzy find a recent directory i start typing a ripgrep command. zsh autofills the command since i've typed it before and i accept it with ctrl-f . i hit ctrl-k f , which tells tmux to search all output in the scrollback for filenames. the filenames are highlighted in blue. i hold n to navigate through the files. there are a lot of them, so it takes me a bit to find the one i'm looking for. i press o to open the selected file in my default application ( nvim ). tmux launches it in a new pane. note that this is still running on the remote server; it is opening a remote file in a remote tmux pane. i do not need to have this codebase cloned locally on my laptop. i try to navigate to several references using rust-analyzer, which fails because RA doesn't understand the macros in this file. at i finally find one which works and navigate to it. i hit ctrl-k h , which tells tmux to switch focus back to the left pane. i hit n again. the pane is still in "copy-mode", so all the files from before are still the focus of the search. they are highlighted again and tmux selects the next file in search order. i hit o , which opens a different file than before, but in the same instance of nvim . i hit b , which shows my open file buffers. in particular, this shows that the earlier file is still open. i switch back and forth between the two files a couple times before ending the stream.

i got annoyed at VSCode a while back for being laggy, especially when the vim plugin was running, and at having lots of keybind conflicts between the editor, vim plugin, terminal, and window management. i tried zed but at the time it was quite immature (and still had the problem of lots of keybind conflicts).

i switched to using nvim in the terminal, but quickly got annoyed at how much time i spent copy-pasting filenames into the editor; in particular i would often copy-paste files with columns from ripgrep, get a syntax error, and then have to edit them before actually opening the file. this was quite annoying. what i wanted was an equivalent of ctrl-click in vscode, where i could take an arbitrary file path and have it open as smoothly as i could navigate to it. so, i started using tmux and built it myself.

people sometimes ask me why i use tmux. this is why! this is the whole reason! (well, this and session persistence.) terminals are stupidly powerful and most of them expose almost none of it to you as the user. i like tmux, despite its age, bugs, and antiquated syntax, because it's very extensible in this way.

this is done purely with tmux config:

bind-key f copy-mode \; send-keys -X search-backward \ ' (^|/| \< |[[:space:]"])(( \. | \. \. )|[[:alnum:]~_"-]*)((/[][[:alnum:]_.#$%&+=@"-]+)+([/ "]| \. ([][[:alnum:]_.#$%&+=@"-]+(:[0-9]+)?(:[0-9]+)?)|[][[:alnum:]_.#$%&+=@"-]+(:[0-9]+)(:[0-9]+)?)|(/[][[:alnum:]_.#$%&+=@"-]+){2,}([/ "]| \. ([][[:alnum:]_.#$%&+=@"-]+(:[0-9]+)?(:[0-9]+)?)|[][[:alnum:]_.#$%&+=@"-]+(:[0-9]+)(:[0-9]+)?)?|( \. | \. \. )/([][[:alnum:]_.#$%&+=@"-]+(:[0-9]+)?(:[0-9]+)?)) '

and this is the contents of search-regex.sh :

... continue reading