Quantcast
Channel: geekoverdose
Viewing all articles
Browse latest Browse all 70

Linux Bash: log commands of all shells immediately to a single command history

$
0
0

One of the useful features of Linux Bash is to search the command history using Ctrl+R. Although the feature is useful I like to tune it’s default config a bit in order to improve my user experience. In the default config the history somehow depends on a) the shell instance you are using (this makes a difference if you use multiple shells at the same time), and b) commands do not get logged immediately to the history. I like to have a command typed in one shell available in the history of all shells immediately.

1. Append all shell commands of all shell to the history
Append the following line to your ~/.bashrc file:

shopt -s histappend

2. Append all shell commands to the history immediately
Append the following line to your ~/.bashrc file:

PROMPT_COMMAND='history -a'

Each Bash opened after these changes will log all commands for all shell instances immediately.

Thx to darksider for having the original idea a long time ago.



Viewing all articles
Browse latest Browse all 70

Trending Articles