Kitty is a fast GPU-based terminal emulator.
This kitten lets you bind keys to either control tabs in Kitty or pass them through to a program running in a Kitty window, depending on whether you, in fact, have any Kitty tabs.
You can use Kitty on its own, and have multiple tabs. In this case, you want to bind easy keys such as Alt+1…0 to switch Kitty tabs.
Alternatively, you can run a terminal multiplexer such as tmux
in Kitty,
perhaps because you want to preserve your session and access it over SSH.
In this case, you want those same keys to switch tmux
windows.
Kitty 0.24.0 or higher.
-
Copy or symlink
smart_tab.py
into your Kitty configuration directory (~/.config/kitty
). -
Edit your
kitty.conf
to add some key shortcuts. -
Restart Kitty.
In all cases, the last argument is a key to send to the active window if the current OS window has only a single tab. If there are two or more tabs, all arguments except the last are executed as a Kitty command.
All the snippets below are only examples. You should choose keys to suit your personal style.
Note that you can use other Kitty commands, but the choice whether to perform the command or send the key to the application will depend on whether you have tabs in the current OS window.
map ctrl+page_down kitty smart_tab.py next_tab ctrl+page_down
map ctrl+page_up kitty smart_tab.py previous_tab ctrl+page_up
map ctrl+shift+t kitty smart_tab.py new_tab alt+shift+t
Note that in this example the key sent to the application is different. This is because terminal emulators typically cannot express a Ctrl+Shift+letter combination.
map ctrl+shift+w kitty smart_tab.py close_tab alt+shift+w
map ctrl+shift+page_down kitty smart_tab.py move_tab_forward ctrl+shift+page_down
map ctrl+shift+page_up kitty smart_tab.py move_tab_backward ctrl+shift+page_up
map ctrl+shift+f2 kitty smart_tab.py set_tab_title ctrl+shift+f2
map alt+1 kitty smart_tab.py goto_tab 1 alt+1
map alt+2 kitty smart_tab.py goto_tab 2 alt+2
…
map alt+9 kitty smart_tab.py goto_tab 9 alt+9
map alt+0 kitty smart_tab.py goto_tab 10 alt+0