Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my laptop, if I type below

$ which vi
alias vi='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!

share|improve this question
up vote 3 down vote accepted

Aliases added to bashrc don't take effect immediately. You have to restart your terminal session or logout and log back in.

To make the alias take effect immediately, run the alias line you added on a terminal as if it were a command or source your bashrc as Nitrodist explains in the first comment.

share|improve this answer
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 or source ~/.bashrc. – Nitrodist May 25 '11 at 17:40
@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 May 25 '11 at 17:48
just executing the file does not make those changes available in your terminal. If I export a variable in the .bashrc and I execute the script instead of sourcing it, then that exported variable disappears after the script finishes executing. See…… and… – Nitrodist May 25 '11 at 18:21
@Nitrodist: I meant run the alias command, but that wasn't very clear in my post. I've updated it. – Patches May 25 '11 at 19:05

You can try to modify the original vi alias set. Here's my grep result:

/etc/profile.d/ alias vi >/dev/null 2>&1 || alias vi=vim
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .