Kitty is cross platform and I use it on both Linux home PC and company Macbook. Sharing the configuration and reuse it is crutial because Kitty is highly scriptable. And changing the configuration once should affect on both of my computers.
Sharing the configuration Link to heading
For this task, I use git to manage the ~/.config
directory. Where most of tools configurations
live. For example kitty
, neovim
, direnv
. The problem is ~/.config
directory is also used
by other applications. But I don’t want git to track everything. So I need to tell git to ignore
everything but the ones I need.
*
!/kitty
Kitty will load default configuration file at ~/.config/kitty/kitty.conf
. So let’s create it.
font_size 14
map ctrl+shift+enter launch --cwd=current
This key map open new kitty window with current working dir instead of home directory.
On Mac we can also use ⌘
+ ↩
key instead of ctrl-shift-enter
. Let’s add an other line for Mac.
map ctrl+shift+enter launch --cwd=current
map cmd+enter launch --cwd=current
This will work just fine on both Linux and Mac, but let’s say I don’t want pressing 🪟+↩
on Linux creates a new window.
And I also want to make font_size
on Linux a little smaller.
How can we check if current OS is Linux or Mac to load the first or second key map?
Configuration by OS Link to heading
Let’s move the 2 mapping commands to 2 different files linux.conf
and macos.conf
.
font_size 12
map ctrl+shift+enter launch --cwd=current
font_size 14
map cmd+enter launch --cwd=current
And tell kitty to include them.
# BEGIN_KITTY_OS_CONFIG
include ${KITTY_OS}.conf
# END_KITTY_OS_CONFIG
The KITTY_OS
variable can take values: linux
, macos
, bsd
.
Reload kitty.conf
by pressing ctr-shift-f5
.