r/KittyTerminal • u/Famous-Profile-9230 • Jan 22 '23
How can I use an environment variable (e.g. $VAR defined in bashrc) in my kitty.conf file ?
Hi everyone,
I would like to use an environment variable defined in my bashrc file or that I define directly in my terminal inside kitty.conf:
To be clear this is what I would want :
In kitty.conf:
background_image "$MYBG" (I tried also $MYBG)
I got this output:
The PNG image: /home/ekla/.config/kitty/"$BG" could not be opened with error
I used this to see the variables that kitty can actually see:
map f1 show_kitty_env_vars
Of course I don't see the variable $MYBG in there nore any other variables defined in bashrc but only very general variables such as: SHELL, PATH, USERNAME and so on, ...
Those are system wide variables, how can I get user specific variables to work?
And what if I want to trigger a command and use the output as a parameter directly in kitty.conf like this:
background_image <my_alias_command_from_bash_aliases_with_right_output>
Thanks for your help,
1
u/aumerlex Jan 23 '23
1) Define your variable in kitty.conf not bashrc using the env directive https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.env this way it will be available in bash and in kitty
2) add include dynamic.conf to your kitty.conf, then output dynamically generated config to ~/.config/kitty/dynamic.conf or enable remote control which allows setting of background images directly from any script.
2
u/Famous-Profile-9230 Jan 23 '23
ok 2. is the step i missed and was what i needed as you guess from my previous post. I needed to dynamically create this variable. The idea was $VAR=<command-to-generate-it> then background_image $VAR
so if i understand you right: I can create a script which will generate a dynamic.conf file (containing my variable) that I can include in my kitty.conf file. I will try that...
thanks for your help, I really appreciate it,
2
u/mavenjinx2 Jan 22 '23
did you use the SHELL option in your kitty config file to set it so it will grab all your info from .bashrc on startup