-
Notifications
You must be signed in to change notification settings - Fork 0
/
git
47 lines (42 loc) · 1.25 KB
/
git
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
#!/bin/bash
function git-branchit {
git rev-parse HEAD > /dev/null 2>&1 &&
git branch --all |
grep -v HEAD |
fzf |
sed 's/.* //'
#git branch --color=always --sort=-committerdate
#fzf --height 50% --ansi --no-multi --preview-window right:65%
#--preview 'git log -n 50 --color=always --date=short --pretty="format:%C(auto)%cd %h%d %s" $(sed "s/.* //" <<< {})'
}
function git-checkit {
git rev-parse HEAD > /dev/null 2>&1 &&
echo '🔀 Pick the branch:' &&
branch=$(git-branchit) &&
[ -n "$branch" ] &&
(
[ "$branch" = "${branch#remotes/}" ] &&
git checkout "$branch" ||
git checkout --track "$branch"
)
}
function git-forgetit {
git rev-parse HEAD > /dev/null 2>&1 &&
echo '🔀 Pick the branch:' &&
branch=$(git-branchit) &&
[ -n "$branch" ] &&
git branch -d "$branch"
}
function git-state {
echo '📜 Status: \n' &&
git status &&
echo '\n📋 Last commit:\n' &&
git last &&
echo '\n⌛ Recent history:\n' &&
git hist
}
function git-branches {
git for-each-ref --sort=-committerdate refs/heads --color=always \
--format='%(refname:short)|%(color:green)%(subject)|%(authorname)|%(committerdate:relative)$(color:reset)' |
column -t -s'|'
}