Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't my vim know my alias?

Tags:

alias

vim

I have 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 must use :!ruby1.9.1

How does alias work? Why vim doesn't know it?

like image 820
Lai Yu-Hsuan Avatar asked Mar 08 '11 16:03

Lai Yu-Hsuan


2 Answers

When Vim starts a process it makes a system call. It has only inherited the environment variables from your shell if you started it from the shell. But it won't know your bash aliases.

Bash aliases are only a convenience when you enter a command line in the Bash shell. They are expanded by Bash only.

If you want real aliases put symlinks in a private hidden folder, and add that folder to your PATH, or use the alternatives facility.

like image 67
Benoit Avatar answered Dec 23 '22 03:12

Benoit


You can try

:set shellcmdflag+=i

to call bass as "interactive" although that does give an annoying message for every shell command executed.

like image 29
Matteo Riva Avatar answered Dec 23 '22 04:12

Matteo Riva