Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

The subject says it all, how to rehash the available executables available within one of the $PATHs after having changed things: e.g. removed a binary from one $PATH which is available in another $PATH, changed the $PATH-variable.

share|improve this question
up vote 36 down vote accepted

hash -r is what needs to be done. In zsh it is rehash and rehash doesn't exist (by default) in bash.

share|improve this answer
2  
rehash is hash -r in zsh. – Ярослав Рахматуллин Oct 22 '12 at 12:25
    
@Jaroslav didn't know, thanks (sry for writing your name in latin). – Patrick B. Oct 22 '12 at 15:04

As Patrick B says, hash -r works. Because I use both shells and rehash has been reinforced in my hind-brain for decades, it comes out of my fingers without asking. To accommodate those reflexes I have added alias rehash='hash -r' to my .aliases_bash file, with I test for and source from .bashrc.

To summarize, in .bashrc I use the line:

    [[ -f ~/.aliases_bash ]] && . ~/.aliases_bash 

and in ``/.aliases_bash` I use the line

    alias rehash='hash -r'
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.