Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've the following alias in ~/.bashrc

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

But it still doesn't prompt me. Am I missing something?

share|improve this question
1  
Did you start a new bash session since changing the file? Did you make sure to load ~/.bashrc (see the INVOCATION section in man bash; essentially, you need to run bash -i) –  Daniel Beck Oct 16 '12 at 18:23
    
@DanielBeck I didn't start a new session, now I did :-) You can type this as an answer and I'll accept it. –  IMB Oct 16 '12 at 18:26
1  
@IMB: Instead of starting a new session, you can also execute source ~/.bashrc. –  Dennis Oct 16 '12 at 18:29

1 Answer 1

up vote 1 down vote accepted

These files – .bashrc and .bash_profile – aren't reloaded automatically after you save changes to them. bash doesn't monitor them for changes, they are only automatically evaluated during bash invocation.

After changing something, you need to explicitly load them. There are basically two ways:

  • source filename or the equivalent . filename will evaluate filename's contents in the current session. This is the easiest, if all you did was add or change existing definitions.
  • Start a new bash session, optionally closing your current one. Depending on how your terminal emulator works, you might need to launch bash -i (for .bashrc) or bash --login (for .bash_profile) explicitly.

In modern, tabbed terminal emulators, this allows you to keep e.g. vi .bashrc open in one tab, edit and save repeatedly, while opening new tabs to test the results. In case you mess it up and the new tabs are not useable, you can also easily revert any changes.

For more information on these files and when bash evaluates them, see man bash's section INVOCATION.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.