Sample Header Ad - 728x90

How can I run my text editor via edit-in-kitty while preserving the environment set in rc files?

1 vote
1 answer
1479 views
### Problem I am trying to get the [edit-in-kitty](https://sw.kovidgoyal.net/kitty/shell-integration/#edit-file) command to work on my local workstation (not over SSH, yet), but it seems like the environment variables — which are usually exported while sourcing my shell's rc file — aren't carried over to the child process while executing this command. This causes a number of errors while starting the editor. To be more specific, the editor is Vim, and examples of issues I am facing include: - The global variable g:colors_name is set based on the value the environment variable BASE16_THEME — which is set in my shell's rc file — and some plugin's theme cannot be applied without it. - Some plugin is looking for an executable inside my PATH, and fails because the PATH visible to Vim is only the system wide PATH (/usr/bin:/bin:/usr/sbin:/sbin). I am quite certain that edit-in-kitty does receive the fully populated environment _during execution_, since it runs my _manually installed_ version of Vim instead of the one that ships with the OS, which is what I expect. To me, it seems like the environment is cleared _right before starting the editor_. Components: - kitty 0.25.2 - zsh 5.8.1 - Vim 9.0 (macOS version, part of MacVim) ### What I tried I set the [env](https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.env) option explicitly inside my kitty configuration to env BASE16_THEME=default-dark, and can confirm that it carries over to Vim when I run edit-in-kitty. Setting PATH in the same fashion, e.g. via env PATH=/custom/bin:${PATH}, would most certainly work too. ### Question The method above doesn't feel very portable to me since the environment depends heavily on my shell's configuration, which varies from system to system. Since kitty [runs the shell to evaluate its environment](https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.editor) , is there a way to instruct it to preserve this environment while launching the text editor?
Asked by Antoine Cotten (113 rep)
Jul 28, 2022, 05:28 PM
Last activity: Jul 29, 2022, 07:28 PM