fix: rework error code writing / simplify it

This commit is contained in:
2025-11-19 09:32:19 +01:00
parent 3555219aa1
commit f6b93d5126

16
.bashrc
View File

@@ -51,16 +51,16 @@ __regenprompt() {
local git=$(__lazy_git_ps1)
if [ $err -ne 0 ]; then
err="\033[s\033[$((COLUMNS - 4))G${err}\033[u"
err="\[\033[$((COLUMNS - 4))G\033[01;31m\]${err}\[\033[0G\]"
else unset err; fi
PS1="\[\033[?25h\]" # show cursor
PS1="$PS1\[\033[01;35m\]\u@\h" # user@host
PS1="$PS1\[\033[00m\]:" # separator
PS1="$PS1\[\033[01;34m\]\w" # working directory
PS1="$PS1\[\033[01;93m\]$git" # git branch
PS1="$PS1\[\033[01;31m\]\[$err\]" # error code
PS1="$PS1\[\033[00m\]\$ " # shell sign
PS1="$err" # error code
PS1="$PS1\[\033[?25h\]" # show cursor
PS1="$PS1\[\033[01;35m\]\u@\h" # user@host
PS1="$PS1\[\033[00m\]:" # separator
PS1="$PS1\[\033[01;34m\]\w" # working directory
PS1="$PS1\[\033[01;93m\]${git}" # git branch
PS1="$PS1\[\033[00m\]\$ " # shell sign
}
PROMPT_COMMAND=__regenprompt