Skip to content

Instantly share code, notes, and snippets.

@walteh
Created April 14, 2025 13:02
Show Gist options
  • Save walteh/2a42715bb27f8f05aa99e514cb94c241 to your computer and use it in GitHub Desktop.
Save walteh/2a42715bb27f8f05aa99e514cb94c241 to your computer and use it in GitHub Desktop.
smart-history.plugin.zsh - a history plugin that makes life easy
# https://zsh.sourceforge.io/Doc/Release/Options.html
# https://postgresqlstan.github.io/cli/zsh-history-options
# https://unix.stackexchange.com/questions/273861/unlimited-history-in-zsh
setopt EXTENDED_HISTORY # include timestamp
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt HIST_BEEP # beep if attempting to access a history entry which isn’t there
setopt HIST_FIND_NO_DUPS # do not display previously found command
setopt HIST_IGNORE_DUPS # do not save duplicate of prior command
setopt HIST_NO_STORE # do not save history commands
setopt HIST_REDUCE_BLANKS # strip superfluous blanks
setopt HIST_SAVE_NO_DUPS # do not save duplicate entries in the history file.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt SHARE_HISTORY # Share history between all sessions. (conflicts with inc_append_history bc it provides this functionality)
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_LEX_WORDS # Perform history expansion on the words following the cursor, not the entire line.
setopt HIST_FCNTL_LOCK # Use fcntl(2) to lock the history file, for thread safety.
setopt HIST_IGNORE_SPACE # do not save if line starts with space (good way to avoid secret keys)
HISTFILE=$HOME/.config/.smart_zsh_history
SAVEHIST=999999999
HISTSIZE=999999999
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment