-
Notifications
You must be signed in to change notification settings - Fork 3
/
aliases
113 lines (95 loc) · 2.63 KB
/
aliases
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# vi: ft=zsh
# a brand new day
alias vim="nvim"
# manage vim bundles
alias plug-install='vim -u "$HOME"/.config/nvim/bundles.vim +PlugInstall +PlugClean! +qa'
alias plug-update='vim -u "$HOME"/.config/nvim/bundles.vim +PlugUpdate +qa'
# tmux
alias ts="tmux start-server"
alias tk="tmux kill-server"
# tmuxifier
# https://github.com/jimeh/tmuxifier
alias tl="tmuxifier list"
alias tls="tmuxifier load-session"
alias tlw="tmuxifier load-window"
# ag
alias ag-filenames='ag -l -G'
alias ag-unrestricted='ag -u'
alias ag-unrestricted-filenames='ag -u -l -G'
alias agf='ag-filenames'
alias agu='ag-unrestricted'
alias aguf='ag-unrestricted-filenames'
# git
alias gc='git commit -v'
alias gco='git checkout'
alias gfa='git fetch --all'
alias gpr='git pull --rebase'
alias gmom='git merge origin/master'
alias gp='git push'
# git log: short
alias gl='git log --pretty=colored'
alias glg='gl --graph'
alias gls='gl --stat'
# git log: complete
alias gll='git log'
alias glgg='gll --graph'
alias glss='gll --stat'
# git-safety-dance: stash a copy of the current branch
# related https://xkcd.com/1296/
git-safety-dance() {
BRANCH=$(git rev-parse --abbrev-ref HEAD)
TIMESTAMP=$(date +%s)
git checkout -b "${BRANCH}-backup-${TIMESTAMP}" &&
git checkout -
}
alias gsd='git-safety-dance'
git-list-merged-branches() {
git checkout master --quiet &&
git branch --merged |
grep -v "\*"
}
alias glmb='git-list-merged-branches'
git-delete-merged-branches() {
git-list-merged-branches |
xargs -n 1 git branch -d
}
alias gdmb='git-delete-merged-branches'
fzf-checkout() {
local tags branches target
tags=$(git tag | awk '{print "\x1b[31;1mtag\x1b[m\t" $1}') || return
branches=$(
git branch --all | grep -v HEAD |
sed "s/.* //" | sed "s#remotes/[^/]*/##" |
sort -u | awk '{print "\x1b[34;1mbranch\x1b[m\t" $1}') || return
target=$(
(echo "$tags"; echo "$branches") |
fzf --no-hscroll --ansi +m -d "\t" -n 2) || return
git checkout $(echo "$target" | awk '{print $2}')
}
alias fco='fzf-checkout'
# diff-so-fancy
# https://github.com/so-fancy/diff-so-fancy
pipe-git-command-to-diff-so-fancy () {
git $@ | diff-so-fancy | less --tabs=4 -RFX
}
# diff
alias git-diff='pipe-git-command-to-diff-so-fancy diff --color'
alias gd='git-diff'
alias gdc='git-diff --cached'
alias gds='git-diff --staged'
# show
alias git-show='pipe-git-command-to-diff-so-fancy show --color'
alias gs='git-show'
# git: alias `g` to `git`
# if called with no arguments run `git status`
unalias g
g() {
if [[ $# > 0 ]]; then
git $@
else
git status
fi
}
compdef g=git
# Include custom aliases
[[ -f ~/.aliases.local ]] && source ~/.aliases.local