Useful settings for history recording in bash (/etc/profile or ~/.bashrc)

shopt -s histappend
shopt -s checkwinsize
export HISTCONTROL=ignoredups:ignorespace
export HISTTIMEFORMAT='%Y-%m-%d %H:%M:%S  '
export EDITOR=vim

histappend: don’t overwrite .bash_history files on each logout; then when someone logs into the server, and messes something up, there’s a vague chance you’ll see what they did. Your history file will obviously grow to be quite big – but suppression of duplicates helps. Mine’s only 900kb after 7 months.

checkwinsize: check the window size after each command, might help some braindead programs cope with you resizing their windows, I guess.

HISTCONTROL: suppress duplicates, ignore spaces

HISTTIMEFORMAT: record a timestamp against each history entry; run ‘history’ to see an example of it’s output…

EDITOR: why would you not use vim?


Posted

in

by

Tags:

Comments

4 responses to “Useful settings for history recording in bash (/etc/profile or ~/.bashrc)”

  1. Duncan Avatar
    Duncan

    export HISTSIZE=10000
    export HISTFILESIZE=10000

    Or some other big number, and stop your history files growing indefinately

  2. […] settings for bash – codepoets.co.uk/2011/useful-settings-for-bash-bashrc-profile/ #unix #linux #sysadmin […]

  3. joco Avatar
    joco

    You have a typo, please change ignoredps to ignoredups.

Leave a Reply

Your email address will not be published. Required fields are marked *