Created
August 23, 2017 11:33
-
-
Save jstn/d249cc4bbb76e0e06ccc6d6a11ff5f04 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
function git_prompt() { | |
local dirty="" | |
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then | |
dirty="*" | |
fi | |
if ! git diff --quiet 2> /dev/null; then | |
dirty="*" | |
fi | |
local ref | |
ref=$(git symbolic-ref --quiet HEAD 2> /dev/null) | |
local ret=$? | |
if [[ $ret != 0 ]]; then | |
[[ $ret == 128 ]] && return | |
ref=$(git rev-parse --short HEAD 2> /dev/null) || return | |
fi | |
echo " %F{cyan}${ref#refs/heads/}%f%F{red}${dirty}%f" | |
} | |
setopt PROMPT_SUBST | |
export PROMPT='[%n@%F{yellow}%m%f:%F{blue}%~%f$(git_prompt)]%# ' | |
export RPROMPT='[%D %*]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment