Skip to content

Commit

Permalink
Add support for custom timestamp format in history
Browse files Browse the repository at this point in the history
  • Loading branch information
CristianCantoro committed Apr 26, 2018
1 parent 9cd3701 commit 7f29de4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 10 additions & 6 deletions lib/history.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 4 additions & 1 deletion templates/zshrc.zsh-template
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down

0 comments on commit 7f29de4

Please sign in to comment.