summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2014-08-20 20:40:35 +0200
committerJan Pokorný <jpokorny@redhat.com>2014-08-20 20:40:35 +0200
commit717923c72371cc894b2f3dc8f34b34abbfde403d (patch)
tree2532fc53e5809d7075339874a88dcadbc5d9b819
parent111a467d4e331e805e49904af0cd8b9b77fd7af7 (diff)
downloaddotfiles-717923c72371cc894b2f3dc8f34b34abbfde403d.zip
dotfiles-717923c72371cc894b2f3dc8f34b34abbfde403d.tar.gz
dotfiles-717923c72371cc894b2f3dc8f34b34abbfde403d.tar.xz
Bash config: tweak cmd prompt: clock in PS1 after 5+ mins
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r--.bash_logout3
-rw-r--r--.bashrc5
2 files changed, 7 insertions, 1 deletions
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}"