diff options
| -rw-r--r-- | bashrc | 47 |
1 files changed, 36 insertions, 11 deletions
@@ -48,17 +48,42 @@ case "$TERM" in esac # prompt -reset='\[\033[0m\]' -yellow_b='\[\033[1;33m\]' -green='\[\033[0;32m\]' -red='\[\033[0;31m\]' -red_b='\[\033[1;31m\]' -[ $(id -u) -eq 0 ] && user_color=$red_b || user_color=$yellow_b -nrjobs='$([ \j -gt 0 ] && echo " [\j]")' -gitps='$(type -t __git_ps1 &>/dev/null && __git_ps1)' -[ -n "$debian_chroot" ] && chroot="[$debian_chroot] " -[ -n "$container" ] && container="[$container] " -PS1=${TITLE}"($user_color\u$reset@$green\h$reset) $container$chroot\W$gitps$nrjobs $red\\\$$reset > " +__prompt_command() { + PS1='${TITLE}' + + local reset='\[\033[0m\]' + local yellow_b='\[\033[1;33m\]' + local green='\[\033[0;32m\]' + local red='\[\033[0;31m\]' + local red_b='\[\033[1;31m\]' + + # user name + [ $(id -u) -eq 0 ] && local user_color=$red_b || local user_color=$yellow_b + PS1+="($user_color\u$reset@$green\h$reset)" + + # chroot / container + if [ -n "$container" ]; then + PS1+=" [$container]" + fi + if [ -n "$debian_chroot" ]; then + PS1+=" [$debian_chroot]" + fi + + # directory base + PS1+=" \W" + + # git + local gitps='$(type -t __git_ps1 &>/dev/null && __git_ps1)' + PS1+="$gitps" + + # background jobs + if [ -n "$(jobs -p)" ]; then + PS1+=" [\j]" + fi + + PS1+=" $red\$$reset > " +} +PROMPT_COMMAND=__prompt_command # history HISTCONTROL='ignoredups:erasedups' |
