5 ms·
selfish question here: Does anybody know how to setup vim so that :! recognises aliases? something like... set shellcmdflag=-O\ expand_aliases\ -c
by freakwit 16y ago
selfish question here: Does anybody know how to setup vim so that :! recognises aliases?
something like...
set shellcmdflag=-O\ expand_aliases\ -c
- cgs1019 16y agoYour aliases are generally sourced from your shell rc file (ie ~/.bashrc). Not sure how vim launches the shell to run ex shell commands but in the interest of portability it's probably just sh with no rc files loaded. This is probably configurable. Try :help shell or :help :! (I'm not at a terminal so not sure what you'll find)
- CamT 16y agoI believe that vim sources env files rather than rc. For example, any aliases placed in my zshenv are available in vim but those in zshrc are not. I would imagine that applies to other shells as well.
- graywh 16y agoZsh always source zshenv, regardless of login/interactive options. AFAIK, Bash has no equivalent.
- graywh 16y agoBy default, Bash, Zsh, and other shells don't source the shell config when started with -c (because it's considered a non-interactive session). For Bash & Zsh, you can force .bashrc/.zshrc to load by adding -i to 'shellcmdflag'.
- Nick_C 16y agoI always start vim from within xterm (bashrc has already run and aliases are already set up). It just works. I can use :!ll (or ctrl-z and 'll' in the sub-shell) and it just works. Not sure why it wouldn't for you.
- graywh 16y agoctrl-z doesn't start a sub-shell, it backgrouns vim and returns you to the parent shell. And maybe he's running gvim or from a login shell that hasn't sourced his bashrc.