Last active
November 30, 2018 10:47
-
-
Save smuuf/6fc58c18f522297d77e49c1f3eca2bdc to your computer and use it in GitHub Desktop.
git status in prompt function
This file contains hidden or 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
#!/bin/bash | |
get_git_status() { | |
git_status=$(git status -s -u -v 2>/dev/null) | |
if [[ -z "$git_status" ]]; then return 0; fi | |
modified=$(echo "$git_status" | grep '^ M ' | wc -l) | |
deleted=$(echo "$git_status" | grep '^ D ' | wc -l) | |
untracked=$(echo "$git_status" | grep '^?? ' | wc -l) | |
echo "(~$modified -$deleted +$untracked) " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment