Created
November 14, 2016 23:50
-
-
Save nathanleclaire/f7235d12e8fef8bdce40bd572dc623a4 to your computer and use it in GitHub Desktop.
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
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