From 63addec61575c9617295907579cef0fa583bcf92 Mon Sep 17 00:00:00 2001 From: Jan Pokorný Date: Mon, 25 Aug 2014 21:56:33 +0200 Subject: Bash config: tweak cmd prompt: show type of exec'd cmd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jan Pokorný --- .bashrc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.bashrc b/.bashrc index 52c23cf..f0953cf 100644 --- a/.bashrc +++ b/.bashrc @@ -60,6 +60,7 @@ HISTCONTROL=ignoreboth # see XXX at preexec (tightly connected) # XXX subshell to avoid triggering DEBUG? (src: http://stuff.lhunath.com/.bashrc) #PROMPT_COMMAND='(trap - DEBUG; history -a)' +_ps_type=. 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.$$" @@ -78,9 +79,10 @@ PS1='\[\033[01;34m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\[\033[$( [ -n "$(find "${_bash_tick}" -mmin -5 2>/dev/null)" ] \ || { _ps_head+="$(date "+%H:%M")${_ps_mc_char}"; touch -- "${_bash_tick}"; } [ "${_postexec_flag_}" -eq 0 ] \ - && printf "0m\]${_ps_lpar}${_ps_head}..${_ps_rpar}" \ + && printf "0m\]${_ps_lpar}${_ps_head}...${_ps_rpar}" \ || { [ ${_ps_ret} -eq 0 ] && printf "1;34m\]" || printf "1;35m\]" - printf "${_ps_lpar}${_ps_head}%0.2x${_ps_rpar}" "${_ps_ret}"; } + printf "${_ps_lpar}${_ps_head}${_ps_type::1}%0.2x${_ps_rpar}" \ + "${_ps_ret}"; } )$\[\033[00m\] ' export ACK=ack @@ -191,6 +193,7 @@ preexec() { test ${BASH_SUBSHELL} -eq 0 && [[ ! "${1}" =~ .*\|.* ]] \ || { _preexec_flag=0; return 0; } _postexec_flag=1 + _ps_type=$(type -t ${1%% *}) case "$1" in apropos\ *|\ colordiff\ *|\ -- cgit