From a1af97a79d52e53b54f46633c7aa81e77d1913ee Mon Sep 17 00:00:00 2001 From: Kamen Mladenov Date: Mon, 4 Nov 2024 09:51:39 +0200 Subject: feat(bash): Show time of command before prompt on enter --- .bashrc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to '.bashrc') diff --git a/.bashrc b/.bashrc index c211a18..e07b67f 100644 --- a/.bashrc +++ b/.bashrc @@ -44,6 +44,7 @@ PS_ERR=160 PS_WARN=172 PS_INFO=97 + PS_DBG=52 hc_mode && PS_TRIANGLE='' || PS_TRIANGLE='/' hc_mode && PS_TRIANGLE_BOT='' || PS_TRIANGLE='\' @@ -172,10 +173,11 @@ export PS_COMM="ps_space; ps_git; ps_exit; ps_duration; ps_dir; ps_nl" export PS1="$(left_cap)\$(ps_user)$(right_cap) \$(ps_precursor) " - export PS0=" $(left_cap 'o' "$PS_TRIANGLE_BOT") \A$(right_cap)\n\$(kill -s SIGUSR2 $$)" + # Show time below command: + # export PS0=" $(left_cap 'o' "$PS_TRIANGLE_BOT") \A$(right_cap)\n\$(kill -s SIGUSR2 $$)" + export PS0="\$(kill -s SIGUSR2 $$)" export PROMPT_COMMAND='EXSTAT="$?";seconds="$SECONDS";___changes="";___git_printed="";'$PS_COMM';___dirchanged=''; ___timer="n"' - # Honorable mention to: https://lists.gnu.org/archive/html/help-bash/2022-02/msg00023.html # }}} # vi mode {{{ @@ -183,6 +185,11 @@ bind 'set show-mode-in-prompt on' bind "set vi-ins-mode-string \"$(left_cap)i$(right_cap)\"" bind "set vi-cmd-mode-string \"$(left_cap $PS_WARN)n$(right_cap $PS_WARN)\"" + + # Huge thanks to: https://lists.gnu.org/archive/html/help-bash/2022-02/msg00023.html + bind -x "\"\xC0\a\":printf \"$(left_cap $PS_DBG)%(%T)T$(right_cap $PS_DBG)\"" + bind '"\xC0\r":accept-line' + bind '"\r":"\xC0\a\xC0\r"' # }}} # History {{{ -- cgit v1.2.3