Same question as this, however the solution there didn’t work.
I set these variables in my ~/.vimrc:
set shellcmdflag=-ic
set shell=/bin/bash\ -i
and I have an alias in my ~/.bash_aliases:
rgr() { if [ ! -z "$2" ]; then grep -rI --exclude=\*.svn\* "$1" * --include=$2 ; else grep -rI --exclude=*svn* "$1" * ; fi ; }
which works when executed from the command line, but when I try to call it from Vim with :!rgr test, I get an error message and Vim exits:
bash: rgr: command not found
[4]+ Stopped vi ~/somefile
If I disable the interactive mode, I just get the “command not found” message and Vim doesn’t exit.
How can I get Vim to recognize my aliases? I’ve reproduced this behavior on both OS X and Ubuntu.
I got this to work, via the man page for
bash:Similarly,
--init-fileworks.Note that
\ -iis not necessary, though it can be added to the command:Example:
~/.bash_profilecontains~/.bash_aliasescontains~/.vimrccontains