How to fix vim throwing error when SHELL is set to xonsh?

194 Views Asked by At

When I start vim I get:

Error detected while processing /home/kossak/.vimrc:
line    1: E484: Can't open file /tmp/vdf7WFR/0
Press ENTER or type command to continue

My first line in ~/.vimrc is let s:uname = system("uname -s").

The error happens because SHELL env var is set to /home/kossak/.local/bin/xonsh. It is set automatically by tmux, because of set -g default-shell /home/kossak/.local/bin/xonsh in my .tmux.conf. I'd like to manually set $SHELL to /bin/bash, without changing default-shell of tmux. Is it possible?

I know I can run tmux setenv -g SHELL '/bin/bash' in CLI and then new panes will have new value, but how to do it in .tmux.conf, so tmux does it automatically for me?

I tried adding setenv -g SHELL '/bin/bash' to .tmux.conf but it doesn't work (the value of $SHELL is not changed).

2

There are 2 best solutions below

0
On BEST ANSWER

Just tell vim to prefer bash, to make your vim consistent.

if executable('bash')
   set shell=bash
endif
0
On

You can't make tmux swap env-vars around, but you can make xonsh do it pretty easily, e.g.

with ${...}.swap({"SHELL": "/bin/bash"}):
    vim

would open vim with your environment mutated to set $SHELL=/bin/bash but only for the body of the context manager.

You could set this as an alias for vim in your xonshrc

def _vim():
    with ${...}.swap({"SHELL": "/bin/bash"}):
        vim

aliases["vim"] = _vim