history.zsh (1464B)
1 ## History wrapper 2 function omz_history { 3 local clear list 4 zparseopts -E c=clear l=list 5 6 if [[ -n "$clear" ]]; then 7 # if -c provided, clobber the history file 8 echo -n >| "$HISTFILE" 9 echo >&2 History file deleted. Reload the session to see its effects. 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 19 # Timestamp format 20 case ${HIST_STAMPS-} in 21 "mm/dd/yyyy") alias history='omz_history -f' ;; 22 "dd.mm.yyyy") alias history='omz_history -E' ;; 23 "yyyy-mm-dd") alias history='omz_history -i' ;; 24 "") alias history='omz_history' ;; 25 *) alias history="omz_history -t '$HIST_STAMPS'" ;; 26 esac 27 28 ## History file configuration 29 HISTSIZE=50000 30 SAVEHIST=10000 31 32 ## History command configuration 33 setopt extended_history # record timestamp of command in HISTFILE 34 setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE 35 setopt hist_ignore_dups # ignore duplicated commands history list 36 setopt hist_ignore_space # ignore commands that start with space 37 setopt hist_verify # show command with history expansion to user before running it 38 setopt inc_append_history # add commands to HISTFILE in order of execution 39 setopt share_history # share command history data