From 8a96cc45c6fce870ca17945499c3230856072ff3 Mon Sep 17 00:00:00 2001 From: Joao Vitorino Date: Thu, 29 Jul 2021 00:12:00 -0300 Subject: [PATCH 1/4] 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 From 6c9ff6c538a26dae954885efffaa4723c2165075 Mon Sep 17 00:00:00 2001 From: jvitorinoj <31418573+jvitorinoj@users.noreply.github.com> Date: Fri, 10 Sep 2021 11:28:42 -0300 Subject: [PATCH 2/4] lib/history (HIST_STAMPS): Remove unecessaries subshells Co-authored-by: Koichi Murase --- lib/history.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/history.sh b/lib/history.sh index 0730c94..6204196 100644 --- a/lib/history.sh +++ b/lib/history.sh @@ -53,8 +53,8 @@ bind '"\e[D": backward-char' # Show history 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 ') ;; + "mm/dd/yyyy") HISTTIMEFORMAT=$'\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ' ;; + "dd.mm.yyyy") HISTTIMEFORMAT=$'\033[31m [%d.%m.%Y] \033[36m[%T]\033[0m ' ;; + "yyyy-mm-dd") HISTTIMEFORMAT=$'\033[31m%Y-%m-%d] \033[36m[%T]\033[0m ' ;; + *) HISTTIMEFORMAT=$'\033[31m%F \033[36m%T\033[0m ' ;; esac From 5a7a9e3c65e0df11f3433087c62b04b1062ca099 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 29 Sep 2022 18:16:28 +0900 Subject: [PATCH 3/4] lib/history (HIST_STAMPS): Adjust format --- lib/history.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/history.sh b/lib/history.sh index 6204196..ecbdad7 100644 --- a/lib/history.sh +++ b/lib/history.sh @@ -54,7 +54,7 @@ bind '"\e[D": backward-char' # Show history case $HIST_STAMPS in "mm/dd/yyyy") HISTTIMEFORMAT=$'\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ' ;; - "dd.mm.yyyy") HISTTIMEFORMAT=$'\033[31m [%d.%m.%Y] \033[36m[%T]\033[0m ' ;; - "yyyy-mm-dd") HISTTIMEFORMAT=$'\033[31m%Y-%m-%d] \033[36m[%T]\033[0m ' ;; + "dd.mm.yyyy") HISTTIMEFORMAT=$'\033[31m[%d.%m.%Y] \033[36m[%T]\033[0m ' ;; + "yyyy-mm-dd") HISTTIMEFORMAT=$'\033[31m[%F] \033[36m[%T]\033[0m ' ;; *) HISTTIMEFORMAT=$'\033[31m%F \033[36m%T\033[0m ' ;; esac From d830c75431c6d7e834bffe902ebd4fd66651519f Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Thu, 29 Sep 2022 19:26:46 +0900 Subject: [PATCH 4/4] lib/history (HIST_STAMPS): do not enclose within [...] by default --- lib/history.sh | 10 ++++++---- templates/bashrc.osh-template | 14 ++++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/history.sh b/lib/history.sh index ecbdad7..90a4c96 100644 --- a/lib/history.sh +++ b/lib/history.sh @@ -53,8 +53,10 @@ bind '"\e[D": backward-char' # Show history case $HIST_STAMPS in - "mm/dd/yyyy") HISTTIMEFORMAT=$'\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ' ;; - "dd.mm.yyyy") HISTTIMEFORMAT=$'\033[31m[%d.%m.%Y] \033[36m[%T]\033[0m ' ;; - "yyyy-mm-dd") HISTTIMEFORMAT=$'\033[31m[%F] \033[36m[%T]\033[0m ' ;; - *) HISTTIMEFORMAT=$'\033[31m%F \033[36m%T\033[0m ' ;; + "[mm/dd/yyyy]") HISTTIMEFORMAT=$'\033[31m[%m/%d/%Y] \033[36m[%T]\033[0m ' ;; + "[dd.mm.yyyy]") HISTTIMEFORMAT=$'\033[31m[%d.%m.%Y] \033[36m[%T]\033[0m ' ;; + "[yyyy-mm-dd]") HISTTIMEFORMAT=$'\033[31m[%F] \033[36m[%T]\033[0m ' ;; + "mm/dd/yyyy") HISTTIMEFORMAT='%m/%d/%Y %T ' ;; + "dd.mm.yyyy") HISTTIMEFORMAT='%d.%m.%Y %T ' ;; + "yyyy-mm-dd"|*) HISTTIMEFORMAT='%F %T ' ;; esac diff --git a/templates/bashrc.osh-template b/templates/bashrc.osh-template index c960ae8..7cdef11 100644 --- a/templates/bashrc.osh-template +++ b/templates/bashrc.osh-template @@ -42,10 +42,16 @@ OSH_THEME="font" # DISABLE_UNTRACKED_FILES_DIRTY="true" # 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" -# IF not set, default value is: yyyy-mm-dd -# HIST_STAMPS="yyyy-mm-dd" +# stamp shown in the history command output. One of the following values can +# be used to specify the timestamp format. +# * 'mm/dd/yyyy' # mm/dd/yyyy + time +# * 'dd.mm.yyyy' # dd.mm.yyyy + time +# * 'yyyy-mm-dd' # yyyy-mm-dd + time +# * '[mm/dd/yyyy]' # [mm/dd/yyyy] + [time] with colors +# * '[dd.mm.yyyy]' # [dd.mm.yyyy] + [time] with colors +# * '[yyyy-mm-dd]' # [yyyy-mm-dd] + [time] with colors +# If not set, the 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