Gentoo Wiki


This article is part of the Tips & Tricks series.
Terminals / Shells Network X Window System Portage System Filesystems Kernel Other

Perhaps this should be collapsed with the article Adjusting Template:The Way Bash History Funtions into a involved bash howto?

Do not remember a command you typed in a few days ago and can not find it because it has already been removed from your .bash_history? Then it is time to increase the number of lines bash keeps in its history file.

File: ~/.bashrc
// # Keep 1000 lines in .bash_history (default is 500)
export HISTSIZE=1000
export HISTFILESIZE=1000
Note: To find commands in your history easily use the ctrl+r shortcut to reverse-search your .bash_history as you type.

If you want to stop bash from creating a history file simply add export HISTFILE=/dev/null to your .bashrc.

To always ignore specific commands use HISTIGNORE.

File: ~/.bashrc
export HISTIGNORE="ls*:fg"

Any command starting with ls or the command fg will now be ignored. Values can be added to this colon-separated list as needed.

Another nice tip is to put export HISTCONTROL=ignoredups into your .bashrc that will stop bash from caching duplicate lines.

From: Gentoo Weekly Newsletter: October 4, 2004, reprinted with permisson.

--SmokesLikeaPoet 06:24, 15 Nov 2004 (GMT)

How-to store commands in different simultaneously running shells in shell history

Sometimes one opens up more than one shell at a time but due to the way that bash works by default, the command history is written to the .bash_history file only when the shell exits. This causes commands entered in one of the shells to be lost/overwritten. To overcome this, solution would be to write to .bash_history as and when a command is executed. This can be done by adding the following two lines to ~/.bashrc

File: ~/.bashrc
shopt -s histappend #makes bash append to history rather than overwrite
PROMPT_COMMAND='history -a' #write to history whenever the prompt is displayed

From: Bash Tips & Tricks - UKUUG Linux 2003 Conference • August 2003

Kb ganesh 08:39, 2 November 2006 (UTC)

Use a better prompt for command line goodness

Retrieved from ""

Last modified: Sun, 15 Jul 2007 09:34:00 +0000 Hits: 24,954