I use vim\'s :! external command function all the time, usually providing % as an argument to the shell command. For example :
:!psql -f %
This answer assumes your vim
isn't actually using bash
to invoke the remote commands - this can be tested by running :!echo $0
in vim
.
Specifically for vim
, add:
set shell=/bin/bash
to your .vimrc
.
In general, there's two strategies I've found to sometimes work when trying to get other programs to invoke my preferred shell:
export SHELL=/bin/bash
in eg. the .profile
file, or:
ln -fsn /bin/bash /bin/sh
which updates the sh
symlink to point to bash
instead.
On many systems (certainly Ubuntu), /bin/sh
is a symlink to a sh
-compatible shell (such as bash
), rather than the sh
shell itself. Given this fact, some programs (I've seen this behaviour in GHC) seem to invoke /bin/sh
, so changing where it points to will cause the programs to use bash
instead.