7 Tips - Tuning Command Line History in Bash - ShellHacks
1. Add Date and Time to Bash History
Sometimes it would be very nice to know when some command got executed.
Set HISTTIMEFORMAT
to print the time stamps associated with each history entry.
Append the following line to ~/.bashrc
file:
export HISTTIMEFORMAT="%h %d %H:%M:%S "
Now, when you type history, it will show something like:
113 Jun 08 16:31:06 sudo ifconfig 114 Jun 08 16:31:10 top 115 Jun 08 16:31:19 ping 8.8.8.8 116 Jun 08 16:31:22 history
2. Increase Bash History Size
Increase HISTSIZE
– the number of commands to remember in the command history (the default value is 500).
export HISTSIZE=10000
Increase HISTFILESIZE
– the maximum number of lines contained in the history file (the default value is 500).
export HISTFILESIZE=10000
3. Append Bash Commands to History File
Bash overwrites .bash_history
file?
To append commands to the history file, rather than overwrite it, add the following line to ~/.bashrc
:
Read full article from 7 Tips - Tuning Command Line History in Bash - ShellHacks
No comments:
Post a Comment