Skip to content

Instantly share code, notes, and snippets.

@notakaos
Created November 2, 2016 02:39
Show Gist options
  • Save notakaos/66ed2bf1fea4fdb009b382a3a14848d0 to your computer and use it in GitHub Desktop.
Save notakaos/66ed2bf1fea4fdb009b382a3a14848d0 to your computer and use it in GitHub Desktop.
Change bash prompt (for Mac)
# export PROMPT="\[\e[0;32m\]$PS1\[\e[m\]"
# export PROMPT="\[\e[0;33m\][\u@\H:\w]\[\e[m\] \n\[\e[0;32m\]\$\[\e[m\] "
# export PROMPT="\[\e[0;33m\][\u@\H:\w]\[\e[m\] \n\[\e[0;32m\]$(echo -en '\U1F363') \[\e[m\] "
# export PROMPT="\[\e[0;33m\][\u@\H:\w]\[\e[m\] \n\[\e[0;32m\]$(echo -en '(´・Д・)')\[\e[m\] "
# ref. http://stackoverflow.com/questions/16715103/bash-prompt-with-last-exit-code
function __prompt_command() {
local EXIT="$?"
local ColRed='\[\e[0;31m\]'
local ColGreen='\[\e[0;32m\]'
local ColYellow='\[\e[0;33m\]'
local ColEnd='\[\e[m\]'
PS1="${ColYellow}[\u@\H:\w]${ColEnd}\n"
if [ $EXIT -eq 0 ]; then
# PS1+="${ColGreen}(´・Д・)${ColEnd}"
PS1+="${ColGreen}(`・ω・´)${ColEnd}"
else
PS1+="${ColRed}(´ ・ω・`).oO($EXIT)${ColEnd}"
fi
PS1+=' '
}
export PROMPT_COMMAND="__prompt_command"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment