On Tue, Feb 10, 2009 at 5:58 PM, Gary Johnson wrote: > > On 2009-02-10, Tony Mechelynck wrote: >> >> On 09/02/09 14:45, WiggyWare wrote: >> > >> > For instance, when I do an 'alias' from :sh, it properly shows me the >> > aliases set up in .kshrc (using ksh). If I do :!alias, I do not get >> > any of the aliases I set up in my .kshrc. >> >> IIUC, Vim runs your usual shell, but as a non-interactive shell. This >> means that bash won't source .bashrc, ksh won't source .kshrc, etc.
Bash also won't source .bash_profile or .profile. See INVOCATION in bash(1) - you'd need to do, say, export BASH_ENV="$HOME/.bashrc" to make that work, and that would probably be a bad idea. >> In Console mode, or when started in GUI mode from a shell, this should >> not be a problem, since in that case Vim runs in an environment set up >> by an earlier (interactive) shell, and passes that to every child process. > > It's still a problem because unlike environment variables, aliases > are not exported to child processes. (I think there are some > exceptions to this, but they don't apply in this case anyway.) There are no exceptions to this. Aliases are held within a shell, there's no way to "pass" an alias to another process. >> To define your aliases even in a non-interactive shell, define them in >> ~/.profile or (system-wide) /etc/profile rather than in .bashrc or >> .kshrc (or the equivalent *rc files for csh, zsh, etc.). > > That doesn't work, at least not for ksh or bash. Nor should it. Aliases are a purely interactive feature, they don't even make sense in non-interactive shells. You can force vim to make shells interactive by tweaking shellcmdflag, or you can force bash to use aliases in non-interactive shells with bash -O expand_aliases alias or shopt -s expand_aliases But anyway, the three general solutions are 1) create scripts instead of aliases, since if you want to use them from within another program aliases aren't even the right tool for the job, 2) ask vim to start interactive shells using 'shellcmdflag', or 3) ask bash to use aliases in non-interactive shells, probably using $BASH_ENV. But, note that 3 has the potential to break distributed scripts, if you define an alias that they expect to use as a function instead... ~Matt --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
