Created
April 19, 2018 13:29
-
-
Save superbob/dbdd9b316706f6e551d8c7bc12701416 to your computer and use it in GitHub Desktop.
A lighter and faster powerlevel9k git vcs segment (for windows)
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
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
vcs segment is slow on windows, this implementation has less functionnalities and is faster.