Kitty
kitty is a fast, feature-rich, GPU based terminal emulator written in C and Python with nice features for the keyboard driven humans like me.
Installation⚑
Although it's in the official repos, the version of Debian (previous to 12) is quite old, instead you can install it for the current user with:
curl -L https://sw.kovidgoyal.net/kitty/installer.sh | sh /dev/stdin
You'll need to add the next alias too to your .zshrc
or .bashrc
alias kitty="~/.local/kitty.app/bin/kitty"
Configuration⚑
It's configuration is a simple, human editable, single file for easy reproducibility stored at ~/.config/kitty/kitty.conf
Print images in the terminal⚑
Create an alias in your .zshrc
:
alias icat="kitty +kitten icat"
Colors⚑
The themes kitten allows you to easily change color themes, from a collection of almost two hundred pre-built themes available at kitty-themes. To use it run:
kitty +kitten themes
The kitten allows you to pick a theme, with live previews of the colors. You can choose between light and dark themes and search by theme name by just typing a few characters from the name.
If you want to tweak some colors once you select a theme, you can use terminal sexy.
Make the background transparent⚑
File: ~/.config/kitty/kitty.conf
background_opacity 0.85
A number between 0 and 1, where 1 is opaque and 0 is fully transparent. This will only work if supported by the OS (for instance, when using a compositor under X11).
If you're using i3wm you need to configure compton
Install it with sudo apt-get install compton
, and configure i3 to start it in the background adding exec --no-startup-id compton
to your i3 config.
Terminal bell⚑
I hate the auditive terminal bell, disable it with:
enable_audio_bell no
Movement⚑
By default the movement is not vim friendly because if you use the same keystrokes, they will be captured by kitty and not forwarded to the application. The closest I got is:
# Movement
map ctrl+shift+k scroll_line_up
map ctrl+shift+j scroll_line_down
map ctrl+shift+u scroll_page_up
map ctrl+shift+d scroll_page_down
If you need more fine grained movement, use the scrollback buffer.
The scrollback buffer⚑
kitty
supports scrolling back to view history, just like most terminals. You can use either keyboard shortcuts or the mouse scroll wheel to do so. However, kitty has an extra, neat feature. Sometimes you need to explore the scrollback buffer in more detail, maybe search for some text or refer to it side-by-side while typing in a follow-up command. kitty allows you to do this by pressing the ctrl+shift+h
key-combination, which will open the scrollback buffer in your favorite pager program (which is less by default). Colors and text formatting are preserved. You can explore the scrollback buffer comfortably within the pager.
To use nvim
as the pager follow this discussion, the latest working snippet was:
# Scrollback buffer
# https://sw.kovidgoyal.net/kitty/overview/#the-scrollback-buffer
# `bash -c '...'` Run everything in a shell taking the scrollback content on stdin
# `-u NORC` Load plugins but not initialization files
# `-c "map q :qa!<CR>"` Close with `q` key
# `-c "autocmd TermOpen * normal G"` On opening of the embedded terminal go to last line
# `-c "terminal cat /proc/$$/fd/0 -"` Open the embedded terminal and read stdin of the shell
# `-c "set clipboard+=unnamedplus"` Always use clipboard to yank/put instead of having to specify +
scrollback_pager bash -c 'nvim </dev/null -u NORC -c "map q :qa!<CR>" -c "autocmd TermOpen * normal G" -c "terminal cat /proc/$$/fd/0 -" -c "set clipboard+=unnamedplus" -c "call cursor(CURSOR_LINE, CURSOR_COLUMN)"'
To make the history scrollback infinite add the next lines:
scrollback_lines -1
scrollback_pager_history_size 0
Clipboard management⚑
# Clipboard
map ctrl+v paste_from_clipboard
Fonts⚑
If you're thinking of adding a new font, you should take a look at the nerd fonts as they patch developer targeted fonts with a high number of glyphs (icons). Specifically to add a high number of extra glyphs from popular ‘iconic fonts’ such as Font Awesome, Devicons, Octicons, and others.
For example you can get the FiraCode Nerd Font
- Add your fonts to the
~/.local/share/fonts
directory - Check they are available when you run
kitty +list-fonts
- Add them to your config:
font_family Operator Mono Book
bold_font Operator Mono Medium
italic_font Operator Mono Book Italic
bold_italic_font Operator Mono Medium Italic
Troubleshooting⚑
Scrollback when ssh into a machine doesn't work⚑
This happens because the kitty terminfo files are not available on the server. You can ssh in using the following command which will automatically copy the terminfo files to the server:
kitty +kitten ssh myserver
This ssh kitten takes all the same command line arguments as ssh, you can alias it to ssh in your shell’s rc files to avoid having to type it each time:
alias ssh="kitty +kitten ssh"
Screen not working on server with sudo⚑
Make sure you're using the ssh alias below
alias ssh="kitty +kitten ssh"
And then copy the ~/.terminfo
into /root
sudo copy -r ~/.terminfo /root
Reasons to migrate from urxvt to kitty⚑
- It doesn't fuck up your terminal colors.
- You can use peek to record your screen.
- Easier to extend.