Skip to content

Instantly share code, notes, and snippets.

@jstncno
Last active September 26, 2017 20:45
Show Gist options
  • Select an option

  • Save jstncno/b88c4e85fe5c1c9387ea to your computer and use it in GitHub Desktop.

Select an option

Save jstncno/b88c4e85fe5c1c9387ea to your computer and use it in GitHub Desktop.
Shell prompt
function prompt {
local BLACK="\[\033[0;30m\]"
local BLACKBOLD="\[\033[1;30m\]"
local RED="\[\033[0;31m\]"
local REDBOLD="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local GREENBOLD="\[\033[1;32m\]"
local YELLOW="\[\033[0;33m\]"
local YELLOWBOLD="\[\033[1;33m\]"
local BLUE="\[\033[0;34m\]"
local BLUEBOLD="\[\033[1;34m\]"
local PURPLE="\[\033[0;35m\]"
local PURPLEBOLD="\[\033[1;35m\]"
local CYAN="\[\033[0;36m\]"
local CYANBOLD="\[\033[1;36m\]"
local WHITE="\[\033[0;37m\]"
local WHITEBOLD="\[\033[1;37m\]"
local GREY="\[\033[0;90m\]"
local RESETCOLOR="\[\e[00m\]"
# python virtualenv
function check_autoenv {
venv=$VIRTUAL_ENV
if [ ${#venv} -ne 0 ]; then
echo "$CYAN(`basename \"$VIRTUAL_ENV\"`)"
fi
}
local FACE="\`if [ \$? = 0 ]; then echo \[\e[33m\]^_^\[\e[0m\]; else echo \[\e[31m\]O_O\[\e[0m\]; fi\`"
function face {
if [ $? = 0 ]; then
echo "\[\e[33m\]^_^\[\e[0m\]"
else
echo "\[\e[31m\]O_O\[\e[0m\]"
fi
}
local GITBRANCH="\`if git rev-parse --abbrev-ref HEAD 2> /dev/null; then echo [$branch]; fi\`"
function gitbranch {
branch=`git rev-parse --abbrev-ref HEAD 2> /dev/null`
if [ $? -eq 0 ]; then
echo [$branch]
fi
}
function gitstatus {
status=`git diff-index --name-only HEAD -- 2> /dev/null`
if [ ${#status} -eq 0 ]; then
echo $GREEN
else
echo $YELLOW
fi
}
export PS1="$BLUE\u$GREY@$RED\h$GREY:$(check_autoenv)$PURPLE\w \n$FACE$GREEN[\#]$(gitstatus)$(gitbranch)$GREEN » $RESETCOLOR"
export PS2=" $GREEN| ↳ $RESETCOLOR"
}
PROMPT_COMMAND=prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment