From 7f29de4726f83d1494c288598eeb8d216c201dc7 Mon Sep 17 00:00:00 2001 From: Cristian Consonni Date: Thu, 26 Apr 2018 07:29:55 +0200 Subject: [PATCH] Add support for custom timestamp format in history --- lib/history.zsh | 16 ++++++++++------ templates/zshrc.zsh-template | 5 ++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/history.zsh b/lib/history.zsh index 7d4e59d00..296cadca4 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -19,12 +19,16 @@ function omz_history { } # Timestamp format -case $HIST_STAMPS in - "mm/dd/yyyy") alias history='omz_history -f' ;; - "dd.mm.yyyy") alias history='omz_history -E' ;; - "yyyy-mm-dd") alias history='omz_history -i' ;; - *) alias history='omz_history' ;; -esac +if [ ! -z "$HIST_STAMPS" ]; then + case $HIST_STAMPS in + "mm/dd/yyyy") alias history='omz_history -f' ;; + "dd.mm.yyyy") alias history='omz_history -E' ;; + "yyyy-mm-dd") alias history='omz_history -i' ;; + *) alias history='omz_history -t "$HIST_STAMPS"' ;; + esac +else + alias history='omz_history' +fi ## History file configuration [ -z "$HISTFILE" ] && HISTFILE="$HOME/.zsh_history" diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index bba2d370d..5f98fb211 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -48,7 +48,10 @@ ZSH_THEME="robbyrussell" # Uncomment the following line if you want to change the command execution time # 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" # Would you like to use another custom folder than $ZSH/custom?