]> src.twobees.de Git - dotfiles.git/blob - stow/oh-my-zsh/.oh-my-zsh/lib/history.zsh
7940769049f3031337fc54d9ce3c33ab4339b323
[dotfiles.git] / stow / oh-my-zsh / .oh-my-zsh / lib / history.zsh
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     fc -p "$HISTFILE"
10     echo >&2 History file deleted.
11   elif [[ -n "$list" ]]; then
12     # if -l provided, run as if calling `fc' directly
13     builtin fc "$@"
14   else
15     # unless a number is provided, show all history events (starting from 1)
16     [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1
17   fi
18 }
19
20 # Timestamp format
21 case ${HIST_STAMPS-} in
22   "mm/dd/yyyy") alias history='omz_history -f' ;;
23   "dd.mm.yyyy") alias history='omz_history -E' ;;
24   "yyyy-mm-dd") alias history='omz_history -i' ;;
25   "") alias history='omz_history' ;;
26   *) alias history="omz_history -t '$HIST_STAMPS'" ;;
27 esac
28
29 ## History file configuration
30 [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"
31 [ "$HISTSIZE" -lt 50000 ] && HISTSIZE=50000
32 [ "$SAVEHIST" -lt 10000 ] && SAVEHIST=10000
33
34 ## History command configuration
35 setopt extended_history       # record timestamp of command in HISTFILE
36 setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
37 setopt hist_ignore_dups       # ignore duplicated commands history list
38 setopt hist_ignore_space      # ignore commands that start with space
39 setopt hist_verify            # show command with history expansion to user before running it
40 setopt share_history          # share command history data