-
Notifications
You must be signed in to change notification settings - Fork 50
/
06_git.zsh
63 lines (60 loc) · 2.19 KB
/
06_git.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
if [[ -x `which git` ]]; then
git_enable=1
alias g=git
alias gco=git-checkout
alias gb=git-branch
alias gam='git-commit -a -m '
function git-branch-name () {
git branch 2> /dev/null | grep '^\*' | sed 's/^\*\ //'
}
function git-dirty () {
git status 2> /dev/null | grep "nothing to commit"
echo $?
}
function gsrb () {
branch=$(git-branch-name)
git checkout master
git svn rebase
git checkout "${branch}"
git rebase master
}
function git-need-to-push() {
if pushtime=$(echo $1 | grep 'Your branch is ahead' 2> /dev/null); then
echo "↑"
fi
}
function git-toggle() {
if [[ $git_enable = 1 ]]; then
git_enable=0
else
git_enable=1
fi
}
function git-prompt() {
dirty_color=$fg[cyan]
if [[ $git_enable = 1 ]]; then
gstatus=$(git status 2> /dev/null)
push_status=$(git-need-to-push $gstatus 2> /dev/null)
branch=$(echo $gstatus | head -1 | sed 's/^On branch //')
dirty=$(echo $gstatus | sed 's/^#.*$//' | tail -2 | grep 'nothing to commit'; echo $?)
if [[ x$branch != x ]]; then
if [[ $dirty = 1 ]] { dirty_color=$fg[magenta] }
[ x$branch != x ] && echo "%{$dirty_color%}$branch%{$reset_color%} $push_status"
fi
else
echo "%{$dirty_color%}!%{$reset_color%} "
fi
}
function git-scoreboard () {
git log | grep '^Author' | sort | uniq -ci | sort -r
}
function git-track () {
branch=$(git-branch-name)
git config branch.$branch.remote origin
git config branch.$branch.merge refs/heads/$branch
echo "tracking origin/$origin"
}
function nhgk () {
nohup gitk --all &
}
fi