Skip to content

Instantly share code, notes, and snippets.

@superbob
Created April 19, 2018 13:29
Show Gist options
  • Save superbob/dbdd9b316706f6e551d8c7bc12701416 to your computer and use it in GitHub Desktop.
Save superbob/dbdd9b316706f6e551d8c7bc12701416 to your computer and use it in GitHub Desktop.
A lighter and faster powerlevel9k git vcs segment (for windows)
prompt_nano_git() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ $CURRENT_BRANCH == "HEAD" ]]; then
COMMIT_ID=$(git rev-parse --short HEAD 2>/dev/null)
if [[ -n $COMMIT_ID ]]; then
CURRENT_BRANCH="$(git rev-parse --short HEAD 2>/dev/null) (detached)"
else
CURRENT_BRANCH="master (empty)"
fi
fi
COUNT_CHANGES=$(git status --porcelain 2>/dev/null | wc -l)
UNTRACKED_CHANGES=$(git status --porcelain 2>/dev/null | egrep "^.\S" | wc -l)
if [[ $COUNT_CHANGES -eq 0 ]]; then
STATUS_COLOR="green"
else
STATUS_COLOR="yellow"
fi
if [[ $UNTRACKED_CHANGES -ne 0 ]]; then
SUFFIX=" $(print_icon 'VCS_UNSTAGED_ICON')"
fi
if [[ -n $CURRENT_BRANCH ]]; then
"$1_prompt_segment" "$0" "$2" "$STATUS_COLOR" "$DEFAULT_COLOR" "$CURRENT_BRANCH$SUFFIX" 'VCS_BRANCH_ICON'
fi
}
@superbob
Copy link
Author

vcs segment is slow on windows, this implementation has less functionnalities and is faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment