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.

Advertisements

Responses

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

    $ history |grep “searchword”

    or

    $ history |more


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: