Hacker News new | ask | show | jobs
by tiny_epoch 2255 days ago
I've had the following in my ~/.bash_profile for quite some time. I leave it here in the hopes it help someone.

  ## History configuration, see HISTORY in bash(1)
  ## builtin fc, aka fix command, for history manipulation
  ## fc [-e ename] [-lnr] [first] [last]
  ##  -e or invoke editor ename; defaults to $FCEDIT
  ##  -l or list commands
  ##  -n or suppress entry numbers
  ##  -r or reverse command order
  ##  first, last selects a range of entries by numeric index
  ##
  ## fc -s [pat=rep] [cmd]
  ##  -s or substitute all occurences of pat with rep
  #
  #  - h() is short for history
  #  - r() is short for replay
  #  - always append to the history, don't overwrite
  #  - save multi-line commands in a single entry
  #  - insist on vim everywhere
  #  - don't record commands with a leading space or duplicates
  #  - constrain the size of the history file
  #  - ignore common things
  #  - constrain the number of history entries
  #  - set up nicer timestamps
  alias h="history"
  alias r="fc -s"
  shopt -s histappend
  shopt -s cmdhist
  export FCEDIT=$EDITOR
  export HISTCONTROL=ignoreboth
  export HISTFILE=$HOME/.bash_history
  export HISTFILESIZE=1048576
  export HISTIGNORE='ls:ls -l:ls -latr:ps -ef:fc:h:history:clear:exit'
  export HISTSIZE=8192
  export HISTTIMEFORMAT='[%F %T]  '
1 comments

Thanks, @tiny_epoch -- that was helpful. :)