• Uncategorized

About linux : How-to-fix-vim-throwing-error-when-SHELL-is-set-to-xonsh

Question Detail

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).

Question Answer

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

if executable('bash')
   set shell=bash

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"}):

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"}):

aliases["vim"] = _vim

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.