git_ahead.fish 495 B

12345678
  1. function git_ahead -a ahead behind diverged none
  2. command git rev-list --count --left-right "@{upstream}...HEAD" 2>/dev/null | command awk "
  3. /^0\t0/ { print \"$none\" ? \"$none\" : \"\"; exit 0 }
  4. /^[0-9]+\t0/ { print \"$behind\" ? \"$behind\" : \"-\"; exit 0 }
  5. /^0\t[0-9]+/ { print \"$ahead\" ? \"$ahead\" : \"+\"; exit 0 }
  6. // { print \"$diverged\" ? \"$diverged\" : \"±\"; exit 0 }
  7. "
  8. end