my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.4 KiB

3 years ago
  1. ## History wrapper
  2. function omz_history {
  3. local clear list
  4. zparseopts -E c=clear l=list
  5. if [[ -n "$clear" ]]; then
  6. # if -c provided, clobber the history file
  7. echo -n >| "$HISTFILE"
  8. fc -p "$HISTFILE"
  9. echo >&2 History file deleted.
  10. elif [[ -n "$list" ]]; then
  11. # if -l provided, run as if calling `fc' directly
  12. builtin fc "$@"
  13. else
  14. # unless a number is provided, show all history events (starting from 1)
  15. [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
  16. fi
  17. }
  18. # Timestamp format
  19. case ${HIST_STAMPS-} in
  20. "mm/dd/yyyy") alias history='omz_history -f' ;;
  21. "dd.mm.yyyy") alias history='omz_history -E' ;;
  22. "yyyy-mm-dd") alias history='omz_history -i' ;;
  23. "") alias history='omz_history' ;;
  24. *) alias history="omz_history -t '$HIST_STAMPS'" ;;
  25. esac
  26. ## History file configuration
  27. [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
  28. [ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
  29. [ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
  30. ## History command configuration
  31. setopt extended_history # record timestamp of command in HISTFILE
  32. setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
  33. setopt hist_ignore_dups # ignore duplicated commands history list
  34. setopt hist_ignore_space # ignore commands that start with space
  35. setopt hist_verify # show command with history expansion to user before running it
  36. setopt share_history # share command history data