.bashrc Beispiele
Applying changes To apply changes from this article to your .bashrc (without ending subshells), do: $ source ~/.bashrc oder $ . .bashrc Or, if you want, you can build your prompt using the ✓ unicode symbol for a zero status and the ✗ unicode symbol for a nonzero status: 0 ✓ andy@alba ~ $ true 0 ✓ andy@alba ~ $ false 1 ✗ andy@alba ~ $ I will try to type a wrong command... bash: I will try to type a wrong command...: command not found 127 ✗ andy@alba ~ $ _ # return value visualisation PS1="[33[01;37m]$? $(if [[ $? == 0 ]]; then echo "[33[01;32m]342234223"; else echo "[33[01;31m]342234227"; fi) $(if [[ ${EUID} == 0 ]]; then echo '[33[01;31m]h'; else echo '[33[01;32m]u@h'; fi)[33[01;34m] w $[33[00m] " Alternatively, this can be made more readable with `PROMPT_COMMAND`: set_prompt () { Last_Command=$? # Must come first! Blue='[e[01;34m]' White='[e[01;37m]' Red='[e[01;31m]' Green='[e[01;32m]' Reset='[e[00m]' FancyX='342234227' Checkmark='342234223' ## Add a bright white exit status for the last command PS1="$White$? " # If it was successful, print a green check mark. Otherwise, print # a red X. if [[ $Last_Command == 0 ]]; then PS1+="$Green$Checkmark " else PS1+="$Red$FancyX " fi # If root, just print the host in red.