Skip to content

Instantly share code, notes, and snippets.

@nathanleclaire
Created November 14, 2016 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanleclaire/f7235d12e8fef8bdce40bd572dc623a4 to your computer and use it in GitHub Desktop.
Save nathanleclaire/f7235d12e8fef8bdce40bd572dc623a4 to your computer and use it in GitHub Desktop.
nocolor="\[\033[0m\]"
lightblue="\[\033[38;05;111m\]"
lightgray="\[\033[38;05;101m\]"
lightgreen="\[\033[38;05;113m\]"
red="\[\033[38;05;196m\]"
export PROMPT_COMMAND=__prompt_command
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/|\1|/'
}
last_cmd_status() {
if [[ "$1" -eq 0 ]]; then
echo "${lightgreen}•"
else
echo "${red}•"
fi
}
__prompt_command() {
local EXIT="$?"
# Append this terminal's history list to history file. This will write the
# history after every command without needing to 'exit' first.
history -a
if [[ $COLUMNS -lt 80 ]]; then
PS1="$ "
else
PS1="$(last_cmd_status "$EXIT")${lightblue}$(parse_git_branch)${lightgray}\w\$ ${nocolor}"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment