Mastering kitty terminal
kitty - the fast, featureful, GPU based terminal emulator
I've been using kitty for quite a long time now. Before it was iTerm and it was slow as my grand-mom's computer. Opening a new tab literally takes forever, I am always starting to type before it is loaded.
My life was desperate and wasteful before I found kitty.
Not that one, this one.
I have tried and used different terminal emulators but prefer this one because it allows me to use less mouse, do the job faster and concentrate on the programming. As a person who uses Emacs in a terminal it's especially important to have a responsive environment.
One thing that I like about it is tabs
. They were made as a simple text.
Kitty allows to control terminal in any way, like send some text to one of the tabs, jump to the tab by name, split windows and run in each of them some command.
One particular feature that I use every day is theme changer.
I wrote a script that loads all themes from the folder, pipes them to fzf
and tells kitty
to change the color scheme when selected.
You can find link to my config in the end of the page, but there are a lot of things so you might be particularly interested in this lines:
Enable remote control in kitty config
... allow_remote_control yes listen_on unix:/tmp/kitty ...
Download kitty themes, google to find more
git clone https://github.com/dexpota/kitty-themes ~/.config/kitty/themes
Create an alias with this command
cd ~/.config/kitty/themes && fzf --preview 'head -n 40 {} && kitty @ --to unix:/tmp/kitty set-colors -a -c {}'; cd -
Now let's find out about kittens - small terminal programs that can be used to extend kitty's functionality.
For example Unicode input.
Another example of kitten: press a shortcut and paste file path from the screen.
I know that there are a lot of programs like fpp
and a lot of plugins for tmux. I played with all of them and none of them worked as good as this one.
You can also choose/copy/insert lines, IPs, URLs or even write your own nice little kitten which will parse the screen by your pattern (e.g. parse and copy timestamps).
But sometimes you might need to select something specific. Well no problema amigo, press another shortcut and buffer output will be redirected to any program you want (vim in my example). Then few presses and voila it's in the clipboard.
You can find vim-ansi file in my config at the end of the page, but here is how to enable it.
Add line below to kitty.conf. pipe
means pipe the buffer of the screen to the command you specified /usr/local/bin/vim-ansi
. @ansi
basically means pass ansi codes, it will allow us to see colored text in vim and overlay
means do it on top of our current screen.
map super+f pipe @ansi overlay /usr/local/bin/vim-ansi
This is quite tricky script which is done to keep colored text of the term and maps q
to exit vim faster and does not copies new line when copying.
#!/bin/sh cat - | awk '/^$/ {nlstack=nlstack "\n";next;} {printf "%s",nlstack; nlstack=""; print;}' > /tmp/buff vim -c 'term tail -n 200 /tmp/buff' -c ':only' -c 'nnoremap q :q!<CR>' -c 'map $ g_' < /dev/tty
Next, I use telegram in terminal so when notification comes and I press on it I will jump right to the correct tab.
Here is an example:
terminal-notifier -title test -message 'Testing kitty remote control' -execute '/usr/local/bin/kitty @ --to unix:/tmp/kitty focus-window && /usr/local/bin/kitty @ --to unix:/tmp/kitty focus-tab --no-response -m title:[replace with you tab title]'
Now, window layouts. A layout is an arrangement of multiple kitty windows inside a top-level OS window. It's nothing new, every terminal has this feature already. But I found it more convenient. You can choose layout on the fly, split window however you want, move it around, etc.
There is nothing special nowadays to be able to view images in a terminal. It's working great, I use it regularly to view pictures/stickers from telegram
.
icat
is just an alias to
alias icat="kitty +kitten icat --align=left"
Conclusion
Kitty has a lot of other cool features and customization, check it out.
I don't want you to convince to use one terminal over another. I want to share my experience and will be happy if it will help somebody (or improve personal life).
P.S. If you did some cool stuff with kitty, please share it.
Helpful links
- My kitty config files - kitty.conf, .zshrc aliases and vim-ansi script
- Kitty config doc