Kitty: Conditional in config file?

Created on 17 Aug 2018  路  9Comments  路  Source: kovidgoyal/kitty

I would like to manage settings across machines in one file and I have some different configs for each of them. Is it possible to put conditionals in config files, e.g. set different font size according to hostname?

I went through the doc for config file and I didn't find anything related to conditionals. I also tried simple bash if else but doesn't seem to work.

Is it possible? If not, are there any workarounds?

Most helpful comment

Got it working thanks.

For anyone else visiting;

edit /etc/enviornment on Ubuntu
and run launchctl setenv VAR variablevalue on mac

All 9 comments

Just do it in your bashrc, something like this:

if [ "$(hostname)" = "home" ]; then
  alias kitty='kitty -c ~/.config/kitty/kitty-home.conf'
fi

@maximbaz thanks for reply. I want to set

macos_hide_titlebar yes

on one machine where chunkwm is installed while macos_hide_titlebar no for others.

Such solution does not seem to work if I use cmd+N to create new window. I think this setting is accessed before bashrc is sourced.

Launching kitty from cmdline works, but I don't think it is a comfortable way to create new windows

Right, my bad, bashrc is not suitable for this, it is loaded already in the new kitty instance. Maybe having this globally will work, like in /etc/profile.d/ ? Or change the command that launches kitty itself, i.e. have a different .desktop file?

Use include device-specific.conf in your kitty.conf, write macos_hide_titlebar yes into device-specific.conf on one machine and leave that file empty on all other devices.

This is a cool idea, probably better than what I was thinking if you mostly share configs between different hosts and have only a few minor differences.

The include directive also expands environment variables in the include file name. So in my kitty.conf I have

include ${HOTNAME}.conf

Of course this implies that the HOSTNAME variable is st system wide on your machine.

I can't seem to get this to work on 0.12.3

When I have in my my kitty.conf file:

include LilArooni.conf # this works great.

include ${HOSTNAME}.conf # does not seem to load -- even though HOSTNAME is set [ubuntu 18.04] -- and HOSTNAME=LilArooni

i tried with including full path names and no dice. what do i seem to be doing wrong?

You need to set the HOSTNAME variable in your global environment ot your shell scripts. Remember that shell scripts are loaded after kitty starts not before. And paths for that directive are relative to the kittyconfig directory

Got it working thanks.

For anyone else visiting;

edit /etc/enviornment on Ubuntu
and run launchctl setenv VAR variablevalue on mac

Was this page helpful?
0 / 5 - 0 ratings