diff --git a/.bashrc b/.bashrc index ff76596..e009a9e 100644 --- a/.bashrc +++ b/.bashrc @@ -50,11 +50,13 @@ __regenprompt() { local err=$? # acquire the error code of the last executed command local git=$(__lazy_git_ps1) + # Format the error code to be in the last column of the terminal + # this shall be printed as non-printable characters, so won't effect text wrapping. if [ $err -ne 0 ]; then - err="\[\033[$((COLUMNS - 4))G\033[01;31m\]${err}\[\033[0G\]" + err="\033[$((COLUMNS - 4))G\033[01;31m${err}\033[0G" else unset err; fi - PS1="$err" # error code + PS1="\[$err\]" # error code PS1="$PS1\[\033[?25h\]" # show cursor PS1="$PS1\[\033[01;35m\]\u@\h" # user@host PS1="$PS1\[\033[00m\]:" # separator