-
Notifications
You must be signed in to change notification settings - Fork 1
/
githelpers
executable file
·52 lines (46 loc) · 1.29 KB
/
githelpers
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
#!/usr/bin/env zsh
numformat() {
if type -a numfmt > /dev/null; then
numfmt "$@"
elif type -a gnumfmt > /dev/null; then
gnumfmt "$@"
else
cat
fi
}
largest() {
topn=${1:-10}
git rev-list --objects --all |
git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |
awk '/^blob/ {print substr($0,6)}' |
sort -k2nr | head -n "$topn" | cut -c 1-12,41- |
numformat --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest
}
# git freeze and thaw
# written by James Macaulay
# https://gist.github.com/jamesmacaulay/582757
freeze() {
local count=0
if git commit -m "WIP [STAGED]" > /dev/null; then
let count+=1
fi
git add --all .
if git commit -m "WIP [UNSTAGED]" > /dev/null; then
let count+=1
fi
if [ $count -eq 0 ]; then
echo "nothing committed"
else
git log -n$count --pretty=format:'%Cgreen%h %Cred%an%Creset: %s'
fi
}
thaw() {
if git rev-list HEAD -n1 --pretty="format:%n" | tail -n1 | grep "^WIP \[UNSTAGED\]$" > /dev/null; then
git reset HEAD^ > /dev/null
fi
if git rev-list HEAD -n1 --pretty="format:%n" | tail -n1 | grep "^WIP \[STAGED\]$" > /dev/null; then
git reset --soft HEAD^ > /dev/null
fi
git status --short
}
"$@"