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

Bash – Continuous String Manipulation

#!/bin/bash FILE="$(basename "$1")" FILE="${FILE/%.jpeg/.jpg}" Is there anyway to glue these two lines together into a one-liner? Answers: Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave … Read more