TID: Setting emacsclient up as a pager with kitty
I recently got a framework laptop on which I am running linux, and decided to give it a run as my main driver, mostly keyboard driven. I want to use a set of 3 editors:
– VSCode because it has copilot and in general seems to be the IDE with the most opensource activity
– emacs because I like the looks of doom emacs, I've used emacs a lot in the past, it has vim bindings and all the snaggles, and I just don't like the vibe of VSCode or vim for that matter (it's all vibes, bro)
– goland/intellij/clion as my main drivers
This time I am going to try to document most of the setup I do, as notes to myself.
So here goes the first: Settings emacsclient up as a pager with kitty.
I want to be able to select parts of my scrollback buffer quickly with kitty, and it seems that the way to do that is to use the shortcut to open the scrollback in the pager, but replace the pager with say vim or emacs.
Now, emacs doesn't allow slurping stdin as a file the way vim does, so I had to write this little workaround, which also strips out the terminal codes I could identify:
#!/bin/bash # Call emacsclient as a pager. # First, read in the content of stdin into a temporary file t=$(mktemp /tmp/emacsclient.XXXXXX) || exit 1 echo "Reading into emacs..." # Remove terminal escape sequences (color and move, as well as some funky starship stuff) cat - \ | sed 's/\x1b\[[0-9;:]*[mGKH]//g' \ | sed 's/\x1b\][0-9;:]*[AC]\x1b\\//g' \ >> $t emacsclient "$t" rm -f $t
And the corresponding kitty.conf entry:
map f1 launch --stdin-source=@screen_scrollback --stdin-add-formatting --type=overlay /home/manuel/.local/bin/emacs-pager.sh