I want to source a file in the same shell process vim was started, from within vim as an ex command. As far as I know, vim creates a new subshell and run commands. In addition to that, If I source a file, and then start vim, vim does not detect the recently added environment variables. (VIm Actually do detect recent exported variables)
Basically, I want to conditionally add some directories to vim's path variable. For the condition, I need to check existence of an environment variable that is come from a file that is sourced.
So, I source a file. It adds some env variable to the current shell. Open vim, run a vim function that checks the existence of an environment variable; if it exists, then append some directories to vim's path
variable.
One solution that came to my mind is that when sourcing that file, set an alias: vim='vim -c "set path+=/path/to/dirs/"'
. But I want to implement the idea in vim script, if that is possible.
Os: linux
vim: v8.2
:!ls
Vim spawns its own child process in which a shell program runs. So what you're requesting isn't really applicable.mkfifo
. Super easy to use. Don't know if they'll fit the bill but it doesn't hurt to look.