From 8a96cc45c6fce870ca17945499c3230856072ff3 Mon Sep 17 00:00:00 2001 From: Joao Vitorino Date: Thu, 29 Jul 2021 00:12:00 -0300 Subject: [PATCH] lib/history (HIST_STAMPS): Make it work and add color --- lib/history.sh | 21 ++++++++++----------- templates/bashrc.osh-template | 3 ++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/history.sh b/lib/history.sh index 18f6b56..0730c94 100644 --- a/lib/history.sh +++ b/lib/history.sh @@ -39,11 +39,6 @@ HISTCONTROL="erasedups:ignoreboth" # Don't record some commands export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear" -# Use standard ISO 8601 timestamp -# %F equivalent to %Y-%m-%d -# %T equivalent to %H:%M:%S (24-hours format) -HISTTIMEFORMAT='%F %T ' - # Enable incremental history search with up/down arrows (also Readline goodness) # Learn more about this here: http://codeinthehole.com/writing/the-most-important-command-line-tip-incremental-hi # bash4 specific ?? @@ -52,10 +47,14 @@ bind '"\e[B": history-search-forward' bind '"\e[C": forward-char' bind '"\e[D": backward-char' +# Use standard ISO 8601 timestamp +# %F equivalent to %Y-%m-%d +# %T equivalent to %H:%M:%S (24-hours format) + # Show history -#case $HIST_STAMPS in - #"mm/dd/yyyy") alias history='fc -fl 1' ;; - #"dd.mm.yyyy") alias history='fc -El 1' ;; - #"yyyy-mm-dd") alias history='fc -il 1' ;; - #*) alias history='fc -l 1' ;; -#esac +case $HIST_STAMPS in + "mm/dd/yyyy") HISTTIMEFORMAT=$(echo -e '\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ');; + "dd.mm.yyyy") HISTTIMEFORMAT=$(echo -e '\033[31m [%d.%m.%Y] \033[36m[%T]\033[0m ') ;; + "yyyy-mm-dd") HISTTIMEFORMAT=$(echo -e '\033[31m%Y-%m-%d] \033[36m[%T]\033[0m ') ;; + *) HISTTIMEFORMAT=$(echo -e '\033[31m%F \033[36m%T\033[0m ') ;; +esac diff --git a/templates/bashrc.osh-template b/templates/bashrc.osh-template index bf37195..c960ae8 100644 --- a/templates/bashrc.osh-template +++ b/templates/bashrc.osh-template @@ -44,7 +44,8 @@ OSH_THEME="font" # 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" -# HIST_STAMPS="mm/dd/yyyy" +# IF not set, default value is: yyyy-mm-dd +# HIST_STAMPS="yyyy-mm-dd" # Uncomment the following line if you do not want OMB to overwrite the existing # aliases by the default OMB aliases defined in lib/*.sh