Why doesn't my vim know my nickname?

I used "alias ruby ​​= ruby1.9.1", so I can execute my ruby ​​with this:

ruby 123.rb

or

ruby1.9.1 123.rb

But in my vim I use :! ruby and get / bin / bash: ruby: command not found.

I have to use :! ruby1.9.1

How does an alias work? Why doesn't vim know this?

+8
vim alias
source share
3 answers

When Vim starts the process, it makes a system call. It only inherited environment variables from your shell if you started it from the shell. But he will not know your bash aliases.

Bash aliases is just a convenience when entering a command line in a bash shell. They expand only bash.

If you want real aliases to place symbolic links in a hidden hidden folder and add this folder to your PATH or use alternatives .

+11
source share

You can try

:set shellcmdflag+=i 

to call the bass as "interactive", although this causes an annoying message for every shell command executed.

+1
source share

Aliases (unlike environment variables) are not inherited by subshells. Therefore, if you want the alias to always be available, you need to install it in your .bashrc file, so each shell instance will receive it at startup

0
source share

All Articles