2
In my laptop, if I type below
$ which vi
alias vi='vim'
/usr/bin/vim
Now I want to change the vi alias to another bin, e.g. vim_wrapper
a script created in /usr/bin/, I type this line:
alias vi="vim_wrapper"
in ~/.bashrc
or /etc/bashrc
, but take no effects. So How to change the default vi alias vi='vim' to vi='vim_wrapper'? Thanks for help!
Not quite the same thing. You have to
source
the file (instead of running it with~/bashrc
on its own), otherwise the changes will not be reflected in the terminal. So, either do. ~/.bashrc
orsource ~/.bashrc
. – Nitrodist – 2011-05-25T17:40:41.707@Nitrodist: Out of curiosity, what is the difference? Obviously your method is better if you add more than one alias or make other changes, but for just adding one alias you'd think both methods would have the same effect. – Patches – 2011-05-25T17:48:40.133
just executing the file does not make those changes available in your terminal. If I export a variable in the
– Nitrodist – 2011-05-25T18:21:53.123.bashrc
and I execute the script instead of sourcing it, then that exported variable disappears after the script finishes executing. See http://superuser.com/questions/176783/what-is-the-difference-between-executing-a-bash-script-and-sourcing-a-bash-script http://stackoverflow.com/questions/1107808/what-happens-when-i-execute-a-unix-shell-script-using-a-command and http://stackoverflow.com/questions/1880735/difference-between-launching-a-script-with-script-sh-and-script-sh@Nitrodist: I meant run the
alias
command, but that wasn't very clear in my post. I've updated it. – Patches – 2011-05-25T19:05:29.023