Last active
August 29, 2015 14:27
-
-
Save amenk/191e21337718ec23c6d7 to your computer and use it in GitHub Desktop.
Bash Prompt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Prompt | |
export PROMPT_COMMAND=__prompt_command # Func to gen PS1 after CMDs | |
function __prompt_command() { | |
local EXIT="$?" # This needs to be first | |
PS1="" | |
local RCol='\[\e[0m\]' | |
local Red='\[\e[0;31m\]' | |
local Gre='\[\e[0;32m\]' | |
local BYel='\[\e[1;33m\]' | |
local BBlu='\[\e[1;34m\]' | |
local Pur='\[\e[0;35m\]' | |
if [ `whoami` == 'root' ]; then | |
PS1+="${Red}\u${RCol}" # Add red if exit code non 0 | |
else | |
PS1+="${Gre}\u${RCol}" | |
fi | |
PS1+="${RCol}@" | |
if [ `hostname` == 'orange' ]; then | |
PS1+="${BBlu}" # Add red if exit code non 0 | |
else | |
PS1+="${Red}" | |
fi | |
PS1+="\h ${Pur}\W${BYel}" | |
if [ $EXIT != 0 ]; then | |
PS1+="${Red} ERR=${EXIT} ${RCol}" | |
fi | |
PS1+="$ ${RCol}" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment