>On Sat, Dec 18, 2010 at 04:41:06PM EST, Roger wrote:
>
>> csupport plugin is awesome!
>>
>> I have one issue with VIM, trying to make it recognize my bashrc aliases.
>>
>> ie:
>> :!indent ./foo.c
>>
>> >From what I've read, the cause is Bash starting in non-interactive mode.
>
>> So I've modified $HOME/.vimrc:
>> shell=bash
>> shellcmdflags=-ic
>
>> Also note, I must specify "-ic", as not even "-i\ -c" will work from within
>> VIM.
>>
>> Is this the proper solution?
>
>Not sure, but this what I did:
>
>1. in .bash_profile I added:
>
> export BASH_ENV="~/.bash_ni"
>
> cf. 'man bash' for details..
>
>2. Then, I created the following ~/.bash_ni file
>
> # ~/.bash_ni: get bash to load aliases & functions for non-interactive
> # shells - e.g. when issuing `:!cmd' commands from Vim
> #set -x
> #---------------------------------------------------------------------
> # functions
> #---------------------------------------------------------------------
> if [ -d /etc/bash_functions ]; then
> cd /etc/bash_functions
> for i in $(ls); do
> . $i
> done
> cd -
> fi
>
> if [ -d /home/gavron/.bash_functions ]; then
> cd /home/gavron/.bash_functions
> for i in $(ls); do
> . $i
> done
> cd -
> fi
> #------------- -------------------------------------------------------
> # source aliases
> #---------------------------------------------------------------------
> shopt -s expand_aliases
>
> if [ -f ~/.bash_aliases ]; then
> . ~/.bash_aliases
> fi
>
>I tend to use bash functions rather than aliases because they are a lot
>more powerful and flexible, hence the functions-related code above. If
>you don't use functions you can skip that part.
>
>cj
Granted, functions are more useful, but I haven't gotten around to really
incorporating any of my own functions into $HOME/.bashrc yet. Aliases can be
written much faster.
The above clippings seem to be a very very good solution. However, think Bash
should be smart enough (ie. have an option) to source any aliases (or functions
in bashrc) if called non-interactively.
--
Roger
http://rogerx.freeshell.org/
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment