File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[alias]
22 add-without-whitespace = !sh -c ' git diff --unified=0 --ignore-all-space "$@" | git apply --cached --unidiff-zero -'
33 to-ssh = !git remote set-url origin $(git remote get-url origin | sed s+https://+git@+ | sed s+/+:+)
4- prompt = !git symbolic-ref HEAD --short 2>/dev/null
54 top-committers = " !_() { \
65 git shortlog -sn --no-merges | head -n${1:-10}; \
76 }; _"
Original file line number Diff line number Diff line change 1+ #! /bin/env sh
2+
3+ # <https://stackoverflow.com/a/59115583>
4+ rebasing-branch () {
5+ for location in rebase-merge rebase-apply; do
6+ path=$( git rev-parse --git-path ${location} )
7+ if test -d ${path} ; then
8+ revision=$( < ${path} /head-name)
9+ echo ${revision## refs/ heads/ }
10+ return 0
11+ fi
12+ done
13+ }
14+
15+ branch () {
16+ git symbolic-ref HEAD --short 2> /dev/null
17+ }
18+
19+ changes () {
20+ STAGED=" $( git diff --cached --name-only 2> /dev/null | wc --lines) s"
21+ WORKTREE=" $( git diff --name-only 2> /dev/null | wc --lines) w"
22+ UNTRACKED=" $( git ls-files --others --exclude-standard 2> /dev/null | wc --lines) u"
23+ echo " ${STAGED}${WORKTREE}${UNTRACKED} " | sed " s/0.//g"
24+ }
25+
26+ PROMPT=$( branch)
27+ if git rev-parse --quiet --verify MERGE_HEAD > /dev/null; then
28+ PROMPT=" $PROMPT [merging]"
29+ elif git rev-parse --quiet --verify REBASE_HEAD > /dev/null; then
30+ PROMPT=" $( rebasing-branch) [rebasing]"
31+ fi
32+ CHANGES=$( changes)
33+ if [[ -n " $CHANGES " ]]; then
34+ PROMPT=" $PROMPT ($CHANGES )"
35+ fi
36+ echo " $PROMPT "
You can’t perform that action at this time.
0 commit comments