selfjungle Just another WordPress weblog

25May/090

Bash history

I took a look around recently how to make life with bash easier and the help of the history is definitely a key issue.

.bashrc:

# enable bash history
set -o history
# bash history file length
export HISTFILESIZE=10000
# multi-line commands are stored in the history
shopt -s cmdhist
# no duplicates and empty lines
export HISTCONTROL=ignoreboth
# do not store lines:
export HISTIGNORE="&:ls:[bf]g:exit"
# append the history to the histfile instead of overwriting it.
shopt -s histappend
# update & re-read histfile after every cmd so terminals will share
export PROMPT_COMMAND="history -n; history -a"

Useful keys

ctrl + r : search in history backward
Page up/down : complete command due to history.

For page up/down part, you need to have the following lines in /etc/inputrc:

"\e[5~": history-search-backward
"\e[6~": history-search-forward

Links

Bash-History-Facilities
Searching for Commands in the History
Keeping bash history in sync on disk and between multiple terminals

Tagged as: Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

 

No trackbacks yet.