2024-02-19 16:07:53 +01:00
|
|
|
function setPromt {
|
2024-03-01 18:00:42 +01:00
|
|
|
if [ "$color_prompt" != yes ]; then
|
|
|
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
case "$TERM" in
|
|
|
|
xterm*|rxvt*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
PROMPT_COMMAND=updatePromt
|
|
|
|
PS2="|"
|
2024-02-19 16:07:53 +01:00
|
|
|
}
|
|
|
|
function updatePromt {
|
2024-03-01 18:00:42 +01:00
|
|
|
local prev_exit="$?"
|
|
|
|
# history -n; history -w; history -c; history -r;
|
|
|
|
# color_helper_>>color<< (Note: \[\]= escaping)
|
|
|
|
local chR="\[\e[1;91m\]" #red
|
|
|
|
local chW="\[\033[00m\]" #white
|
|
|
|
local chG="\[\033[01;32m\]" #green
|
|
|
|
local chB="\[\033[0;34m\]" #blue
|
|
|
|
local chP="\[\033[0;35m\]" #purple
|
|
|
|
local chY="\[\033[0;33m\]" #yellow
|
|
|
|
PS1=""
|
|
|
|
if [ $prev_exit == 0 ]; then
|
|
|
|
PS1+="$chG✓ $chW"
|
|
|
|
else
|
|
|
|
PS1+="$chR✗ $chW"
|
|
|
|
fi
|
|
|
|
local jobs="$(jobs | wc -l)"
|
|
|
|
if [ $jobs != 0 ]; then
|
|
|
|
PS1+="${chY}≡$jobs$chW"
|
|
|
|
fi
|
|
|
|
PS1+="${debian_chroot:+($debian_chroot)}"
|
|
|
|
PS1+=" At ${chG}\A${chW}"
|
|
|
|
PS1+=" by ${chP}\u${chW}"
|
|
|
|
if sudo -n true 2>/dev/null; then
|
|
|
|
PS1+="${chR} (sudo)${chW}"
|
|
|
|
fi
|
|
|
|
PS1+=" in "
|
|
|
|
if \git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
|
|
local branch="$(\git symbolic-ref -q HEAD)"
|
|
|
|
PS1+="[${branch#refs/heads/}"
|
|
|
|
local status="$(git for-each-ref --format='%(upstream:trackshort)' refs/heads | awk '!seen[$1]++ {printf $1}')"
|
|
|
|
status+="$(git status --porcelain | awk '!seen[$1]++ {printf $1}')"
|
|
|
|
if [ "$statua"s ]; then
|
|
|
|
PS1+="|$chY$status$chW"
|
|
|
|
fi
|
|
|
|
PS1+="] "
|
|
|
|
fi
|
|
|
|
PS1+="${chB}\w${chW}"
|
2024-10-11 09:25:12 +02:00
|
|
|
if [ ! -z ${PS1_jaaENV+x} ]; then
|
|
|
|
PS1+="\n$PS1_jaaENV"
|
|
|
|
else
|
|
|
|
PS1+="\n:"
|
|
|
|
fi
|
2024-03-01 18:00:42 +01:00
|
|
|
history -a
|
2024-02-19 16:07:53 +01:00
|
|
|
}
|
|
|
|
setPromt
|
|
|
|
unset color_prompt
|
|
|
|
unset -f setPromt
|
|
|
|
|
|
|
|
# vim: set filetype=sh tabstop=4 shiftwidth=4 textwidth=250 expandtab :
|