Bash: Display exit status in prompt:

GREEN="e[1;32m" RED="e[1;31m" NONE="e[m" get_exit_status(){ es=$? if [ $es -eq 0 ] then echo -e "${GREEN}${es}${NONE}" else echo -e "${RED}${es}${NONE}" fi } get_path(){ #dummy function echo "PATH" } PROMPT_COMMAND='exitStatus=$(get_exit_status)' The following gives me the correct exitStatus but colour variables are not expanded: PS1='${RED}h $(get_path) ${exitStatus}${NONE} ' However, the one below, gives me the colours but the … Read more