Thoughts on System Administration

12 March, 2008

Bash History

Filed under: Meta, Quick Tips — Tags: — plathrop @ 10:35 am

Here are a couple of tips for more effective use of your Bash command history. I think the Ctrl-R trick will save me a lot of typing.

I have some articles planned, but have been busy starting my new job. Those few of you who actually read this, don’t worry - I’ll be back.

1 Comment »

  1. My favorite bash history recipe (in .bash_profile, .bashrc, wherever …):

    # remove duplicate entries from history …
    export HISTCONTROL=erasedups

    # keep a good size backlog …
    export HISTSIZE=10000

    # bind up and down arrow keys
    bind ‘”\e[A”‘:history-search-backward
    bind ‘”\e[B”‘:history-search-forward

    # append history to .bash_history on shell exit, rather than overwriting
    shopt -s histappend

    With this, you can type the first few characters of anything in your history, then use the up and down arrow keys to search for the appropriate entry. Sweet!

    Comment by Mashmore — 10 October, 2008 @ 12:21 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment