Etikettarkiv: interactive

Your favourite prompt

Today’s Bash tip. Create a prompt that changes face depending on the return code of your last command. As long as the return code is OK you get a happy face. When it is false you get a sad one.

Open and edit the .bashrc file in your home directory and enter the following:

PS1="\u@\h:\[\e[33m\]\w\[\e[0m\] \[\`if [[ \$? = "0" ]]; \
then echo '\e[32m=)\e[0m'; else echo '\e[31m=(\e[0m' ; fi\`\] \$ "

Have fun.