I want to display a green smile face if the previous exit code is 0 and red smile face if not successful.
Basically I want to do this prompt but with other stuff in
I adapted Michael A's answer for a .bashrc
file (in my case, git-for-windows)
PS1='\
`if [[ $? -gt 0 ]]; then printf "\[\033[01;31m\]:("; else printf "\[\033[01;32m\]:)"; fi`\
\[\033]0;$TITLEPREFIX:$PWD\007\] \
\[\033[32m\]\u@\h \
\[\033[33m\]\w\
\[\033[36m\]`__git_ps1`\
\[\033[0m\]\n$'
For reference the default is:
PS1='\
\[\033]0;$TITLEPREFIX:$PWD\007\]\n\
\[\033[32m\]\u@\h\
\[\033[35m\] $MSYSTEM \
\[\033[33m\]\w\
\[\033[36m\]`__git_ps1`\
\[\033[0m\]\n$'