in vim when i try to do something like this:
:!ls
i get==>> cannot execute shell /usr/local/bin/bash which is logical
since my bash is at /bin/bash. Is there anyway to point vim to the
correct path?
thanks in advance,
nicolas
You can explicitly set the 'shell' option to /bin/bash. Vim gets it's
default from the $SHELL environment variable. Some vim init script
might be overwriting the default with a bad value. You can use
":verbose set shell" to find out where that might be happening.
the "verbose set shell", saved my day!
thank you Cory!
the "verbose set shell", saved my day!
Technically, it's an option in Vim, not a variable.
:set shell=/bin/bash
(put it in your .vimrc or something).
To set the $SHELL environment variable from which Vim automatically sets
its shell option when it starts up, you have to do something like
export SHELL=/bin/bash
or
setenv SHELL /bin/bash
in your shell login/initialisation scripts (~/.profile or ~/.login
probably). See your shell man page for the gory details.
It is odd for these values to be wrong, though, if your logins are
actually working. If something is not working, it is more likely that
some rogue Vim script is changing the option or shell script is setting
environment variable, when it shouldn't.
Ben.
> <mailto:n.agg...@gmail.com>> wrote:Technically, it's an option in Vim, not a variable.
>
>
> thank you Cory!
>
> the "verbose set shell", saved my day!
>
>
> So how do I explicitly set the VIM shell variable?
:set shell=/bin/bash
(put it in your .vimrc or something).
> One last Q, Is it possible for VIM to "recognize" my aliases, such as I have
> in my .aliases for example?- (in bash I simply source them of course)
Vim doesn't know anything about how a shell invokes a command,
including whether that command is a built-in, an alias, a function
or a file. What you really want to know is whether aliases can be
used by a shell invoked from vim.
Bash "normally" sources ~/.bashrc only if it is run as an
interactive shell. This improves the performance of the shell when
it is run in non-interactive mode, where aliases are usually not
used. If you want the shell invoked from vim to see your aliases,
you can either tell vim to always invoke the shell in interactive
mode or tell the shell to always source ~/.bashrc even when not in
interactive mode.
For the former, I think (untested) that adding "-i" to
'shellcmdflag' will work, e.g.,
set shcf=-i\ -c
For the latter, you'll need to set the appropriate environment
variable in your ~/.profile or ~/.bash_profile. See the bash man
page, especially the INVOCATION section. I think the variable you
want is BASH_ENV.
HTH,
Gary
Vim doesn't know anything about how a shell invokes a command,
On 2008-12-10, yosi izaq wrote:
> One last Q, Is it possible for VIM to "recognize" my aliases, such as I have
> in my .aliases for example?- (in bash I simply source them of course)
including whether that command is a built-in, an alias, a function
or a file. What you really want to know is whether aliases can be
used by a shell invoked from vim.
Bash "normally" sources ~/.bashrc only if it is run as an
interactive shell. This improves the performance of the shell when
it is run in non-interactive mode, where aliases are usually not
used. If you want the shell invoked from vim to see your aliases,
you can either tell vim to always invoke the shell in interactive
mode or tell the shell to always source ~/.bashrc even when not in
interactive mode.
For the former, I think (untested) that adding "-i" to
'shellcmdflag' will work, e.g.,
set shcf=-i\ -c
Hmm. I just tried it with ksh and got the same results. A command
like this one,
ksh -i -c 'ct ls'
works fine from the command line, so those options are OK. (ct is
an alias for cleartool.) I don't know what it is that causes
set shellcmdflag=-i\ -c
to fail. However, this variation does work:
set shellcmdflag=-ic
Regards,
Gary
Quoting.
~> "bash" "-i -c" "ls"
bash: - : invalid option
~> "bash" "-i" "-c" "ls"
(works as desired)
setting shellcmdflag to '-i -c' makes that be passed as one argument
to bash, so bash sees "-" meaning "start some short flags", then "i"
meaning interactive, then " " - and it barfs there.
~Matt