From 717923c72371cc894b2f3dc8f34b34abbfde403d Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Wed, 20 Aug 2014 20:40:35 +0200 Subject: Bash config: tweak cmd prompt: clock in PS1 after 5+ mins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- .bash_logout | 3 +++ .bashrc | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .bash_logout diff --git a/.bash_logout b/.bash_logout new file mode 100644 index 0000000..80562a5 --- /dev/null +++ b/.bash_logout @@ -0,0 +1,3 @@ +# ~/.bash_logout + +[ -f "${_bash_tick}" ] && rm -f -- "${_bash_tick}" diff --git a/.bashrc b/.bashrc index 2f32f5a..7a40d82 100644 --- a/.bashrc +++ b/.bashrc @@ -62,6 +62,7 @@ HISTCONTROL=ignoreboth #PROMPT_COMMAND='(trap - DEBUG; history -a)' PROMPT_COMMAND='(history -a; [ ${_postexec_flag} -ne 0 ]) \ && _postexec_flag_=${_postexec_flag} || _postexec_flag_=0' +_bash_tick="${XDG_RUNTIME_DIR:-${TMPDIR:-/var/run}}/_bash_tick.$$" PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\[\033[$( _ret=$? [ -n "${MC_SID}" ] && _mc_char="#" || _mc_char="|" @@ -73,7 +74,9 @@ PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\[\033[$( || _head=C; } \ || _head=S; } \ || _head="$(($(dirs -p | head -n9 | wc -l) - 1))" - _head+=${_mc_char} + _head+="${_mc_char}" + [ -n "$(find "${_bash_tick}" -mmin -5 2>/dev/null)" ] \ + || { _head+="$(date "+%H:%M")${_mc_char}"; touch -- "${_bash_tick}"; } [ "${_postexec_flag_}" -eq 0 ] && printf "0m\]${_lpar}${_head}..${_rpar}" || { [ ${_ret} -eq 0 ] && printf "1;34m\]" || printf "1;35m\]" printf "${_lpar}${_head}%0.2x${_rpar}" "${_ret}" -- cgit