Skip to content

Instantly share code, notes, and snippets.

@smuuf
Last active November 30, 2018 10:47
Show Gist options
  • Save smuuf/6fc58c18f522297d77e49c1f3eca2bdc to your computer and use it in GitHub Desktop.
Save smuuf/6fc58c18f522297d77e49c1f3eca2bdc to your computer and use it in GitHub Desktop.
git status in prompt function
#!/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