history.zsh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ## History wrapper
  2. function omz_history {
  3. # Delete the history file if `-c' argument provided.
  4. # This won't affect the `history' command output until the next login.
  5. if [[ "${@[(i)-c]}" -le $# ]]; then
  6. echo -n >| "$HISTFILE"
  7. echo >&2 History file deleted. Reload the session to see its effects.
  8. elif [[ "${@[(i)-l]}" -le $# ]]; then
  9. builtin fc "$@"
  10. else
  11. builtin fc "$@" -l 1
  12. fi
  13. }
  14. # Timestamp format
  15. case $HIST_STAMPS in
  16. "mm/dd/yyyy") alias history='omz_history -f' ;;
  17. "dd.mm.yyyy") alias history='omz_history -E' ;;
  18. "yyyy-mm-dd") alias history='omz_history -i' ;;
  19. *) alias history='omz_history' ;;
  20. esac
  21. ## History file configuration
  22. [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
  23. HISTSIZE=10000
  24. SAVEHIST=10000
  25. ## History command configuration
  26. setopt append_history # append history to HISTFILE on session exit
  27. setopt extended_history # record timestamp of command in HISTFILE
  28. setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
  29. setopt hist_ignore_dups # ignore duplicated commands history list
  30. setopt hist_ignore_space # ignore commands that start with space
  31. setopt hist_verify # show command with history expansion to user before running it
  32. setopt inc_append_history # add commands to HISTFILE in order of execution
  33. setopt share_history # share command history data