Posted by: rydow | June 20, 2007

Bash history

Today’s topic is bash history. Everybody knows that up arrow scrolls to the previous command written. What not so many people know is that the CTRL+r starts a search backwards in the history. This feature may be quite handy when you wrote a long command line some days ago.

I usually add this to my .bashrc:

 # Rebind arrow keys
bind ‘”\e[A”: history-search-backward’
bind ‘”\e[B”: history-search-forward’
bind ‘”\e[C”: forward-char’
bind ‘”\e[D”: backward-char’

to get the up and down key work with history search every time.

Someone said that the only thing we can learn from history is that nothing may be learnt from history. Well not entirely true in this case.


Responses

  1. nice,… usually I just used the following:

    $ history |grep “searchword”

    or

    $ history |more


Leave a response

Your response:

Categories