Skip to content

Instantly share code, notes, and snippets.

@ArsenArsen
Created Jan 19, 2017
Embed
What would you like to do?
My PS1
function parseBranch() {
BRANCH="$(git rev-parse --symbolic-full-name --abbrev-ref HEAD 2>/dev/null)"
if [ ! "${BRANCH}" == "" ]
then
echo " [$BRANCH]";
fi
}
function parseExitCode() {
CODE=$?
if [ ! "${CODE}" == "0" ]
then
echo " ${CODE}"
fi
}
BOLD="\[$(tput bold)\]"
CYAN="\[$(tput setaf 6)\]"
RED="\[$(tput setaf 1)\]"
GREEN="\[$(tput setaf 2)\]"
RESET="\[$(tput sgr0)\]"
PS1="$BOLD$GREEN\u@\h$RESET$BOLD:$RESET$CYAN\w$RED\`parseExitCode\`$BOLD$GREEN\`parseBranch\`$RESET\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment