diff options
author | Jan Pokorný <jpokorny@redhat.com> | 2014-08-25 21:56:33 +0200 |
---|---|---|
committer | Jan Pokorný <jpokorny@redhat.com> | 2014-08-25 21:57:56 +0200 |
commit | 63addec61575c9617295907579cef0fa583bcf92 (patch) | |
tree | bdd80ea2151c1a61324bc298785725b92a854ee1 | |
parent | af0f6a68b9d1b18a44c26b62199983d8ac0135c4 (diff) | |
download | dotfiles-63addec61575c9617295907579cef0fa583bcf92.tar.gz dotfiles-63addec61575c9617295907579cef0fa583bcf92.tar.xz dotfiles-63addec61575c9617295907579cef0fa583bcf92.zip |
Bash config: tweak cmd prompt: show type of exec'd cmd
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
-rw-r--r-- | .bashrc | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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\ *|\ |