Add support for custom timestamp format in history

This commit is contained in:
Cristian Consonni 2018-04-26 07:29:55 +02:00
commit 7f29de4726
No known key found for this signature in database
GPG key ID: 4467EF2D604D387C
2 changed files with 14 additions and 7 deletions

View file

@ -19,12 +19,16 @@ function omz_history {
} }
# Timestamp format # Timestamp format
case $HIST_STAMPS in if [ ! -z "$HIST_STAMPS" ]; then
"mm/dd/yyyy") alias history='omz_history -f' ;; case $HIST_STAMPS in
"dd.mm.yyyy") alias history='omz_history -E' ;; "mm/dd/yyyy") alias history='omz_history -f' ;;
"yyyy-mm-dd") alias history='omz_history -i' ;; "dd.mm.yyyy") alias history='omz_history -E' ;;
*) alias history='omz_history' ;; "yyyy-mm-dd") alias history='omz_history -i' ;;
esac *) alias history='omz_history -t "$HIST_STAMPS"' ;;
esac
else
alias history='omz_history'
fi
## History file configuration ## History file configuration
[ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history"

View file

@ -48,7 +48,10 @@ ZSH_THEME="robbyrussell"
# Uncomment the following line if you want to change the command execution time # Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output. # stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" # You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy" # HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom? # Would you like to use another custom folder than $ZSH/custom?