-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaliases
executable file
·223 lines (181 loc) · 7.69 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
get_default_branch() {
git remote show origin | sed -n '/HEAD branch/s/.*: //p'
}
# retry with sudo
alias s='sudo $(fc -ln -1)'
# apt
alias apts='apt-cache search --names-only'
alias aptshow='apt-cache show'
alias aptinst='sudo apt-get install -V'
alias aptupd='sudo apt-get update'
alias aptupg='sudo apt-get dist-upgrade -V && sudo apt-get autoremove'
alias aptupgd='sudo apt-get update && sudo apt-get dist-upgrade -V && sudo apt-get autoremove'
alias aptrm='sudo apt-get remove'
alias aptpurge='sudo apt-get remove --purge'
alias chkup='/usr/lib/update-notifier/apt-check -p --human-readable'
alias chkboot='cat /var/run/reboot-required'
alias pkgfiles='dpkg --listfiles'
# tmux
alias txl='tmux ls'
alias txn='tmux new -s'
alias txa='tmux a -t'
# git
alias g='git'
alias get='git'
# log
alias gg='git log --graph --all --pretty=format:'\''%C(bold)%h%Creset%C(auto)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset'\'' --abbrev-commit --date=relative'
alias ggf='git log --graph --date=short --pretty=format:'\''%C(auto)%h %Cgreen%an%Creset %Cblue%cd%Creset %C(auto)%d %s'\'''
alias ggs='gg --stat'
alias ggup='git log --branches --not --remotes --no-walk --decorate --oneline' # FROM https://stackoverflow.com/questions/39220870/in-git-list-names-of-branches-with-unpushed-commits
alias gll='git log --graph --pretty=oneline --abbrev-commit'
alias gnew='git log HEAD@{1}..HEAD@{0}' # Show commits since last pull, see http://blogs.atlassian.com/2014/10/advanced-git-aliases/
alias gwc='git whatchanged'
gs() {
git fetch
main=$(get_default_branch)
num_commits=$(git rev-list --count origin/"$main"..."$main")
num_commits_to_show=$(( $num_commits < 5 ? 5 : $num_commits ))
echo "" && git status -s && echo "" && gg HEAD~${num_commits_to_show}...@{upstream}
}
# add
function ga() { git add "${@}" && gs; }
function gaa() { git add -A "${@}" && gs; }
function gap() { git add -p "${@}" && gs; }
function gav(){ git add -v "${@}" && gs; }
# branch
function gb() { git branch "${@}" && gs; }
function gba() { git branch --all "${@}" && gs; }
function gbd() { git branch -d "${@}" && gs; }
function gbD() { git branch -D "${@}" && gs; }
function gbl() { git branch --list "${@}" && gs; }
function gbla() { git branch --list --all "${@}" && gs; }
function gblr() { git branch --list --remotes "${@}" && gs; }
function gbm() { git branch --move "${@}" && gs; }
function gbr() { git branch --remotes "${@}" && gs; }
function gbt() { git branch --track "${@}" && gs; }
function gdel() { git branch -D "${@}" && gs; }
# for-each-ref
alias gbc='git for-each-ref --format="%(authorname) %09 %(if)%(HEAD)%(then)*%(else)%(refname:short)%(end) %09 %(creatordate)" refs/remotes/ --sort=authorname DESC' # FROM https://stackoverflow.com/a/58623139/10362396
# commit
function gc() { git commit -v "${@}" && gs; }
function gca() { git add --all && git commit -v "${@}" && gs; }
function gcaa() { git commit -a --amend -C HEAD "${@}" && gs; } # Add uncommitted and unstaged changes to the last commit
function gcam() { git commit -v -am "${@}" && gs; }
function gcamd() { git commit --amend "${@}" && gs; }
function gcm() { git commit -v -m "${@}" && gs; }
function gci() { git commit --interactive "${@}" && gs; }
function gcsam() { git commit -S -am "${@}" && gs; }
# checkout
function gcb() { git checkout -b "${@}" && gs; }
function gco() { git checkout "${@}" && gs; }
function gcob() { git checkout -b "${@}" && gs; }
function gcobu() { git checkout -b ${USER}/ "${@}" && gs; }
function gcom() { git checkout $(get_default_branch) "${@}" && gs; }
function gcpd() { git checkout $(get_default_branch); git pull; git branch -D "${@}" && gs; }
function gct() { git checkout --track "${@}" && gs; }
# clone
function gcl() { git clone "${@}" && gs; }
# clean
function gclean() { git clean -fd "${@}" && gs; }
# cherry-pick
function gcp() { git cherry-pick "${@}" && gs; }
function gcpx() { git cherry-pick -x "${@}" && gs; }
# diff
alias gd='git diff'
alias gds='git diff --staged'
alias gdt='git difftool'
# archive
alias gexport='git archive --format zip --output'
# fetch
alias gf='git fetch --all --prune'
function gft() { git fetch --all --prune --tags "${@}" && gs; }
function gftv() { git fetch --all --prune --tags --verbose "${@}" && gs; }
function gfv() { git fetch --all --prune --verbose "${@}" && gs; }
function gmu() { git fetch origin -v; git fetch upstream -v; git merge upstream/$(get_default_branch) "${@}" && gs; }
function gup() { git fetch && git rebase "${@}" && gs; }
# ls-files
alias gu='git ls-files . --exclude-standard --others' # Show untracked files
alias glsut='gu'
alias glsum='git diff --name-only --diff-filter=U' # Show unmerged (conflicted) files
# gui
alias ggui='git gui'
# home
alias ghm='cd "$(git rev-parse --show-toplevel)"' # Git home
# merge
function gm() { git merge "${@}" && gs; }
# mv
function gmv() { git mv "${@}" && gs; }
# patch
function gpatch() { git format-patch -1 "${@}" && gs; }
# push
function gp() { git push "${@}" && gs; }
function gpd() { git push --delete "${@}" && gs; }
function gpf() { git push --force "${@}" && gs; }
function gpo() { git push origin HEAD "${@}" && gs; }
function gpom() { git push origin $(get_default_branch) "${@}" && gs; }
function gpu() { git push --set-upstream "${@}" && gs; }
function gpunch() { git push --force-with-lease "${@}" && gs; }
function gpuo() { git push --set-upstream origin "${@}" && gs; }
function gpuoc() { git push --set-upstream origin $(git symbolic-ref --short HEAD) "${@}" && gs; }
# pull
function gl() { git pull --rebase "${@}" && gs; }
function glum() { git pull upstream $(get_default_branch) "${@}" && gs; }
function gpp() { git pull --rebase && git push "${@}" && gs; }
function glm() { git pull "${@}" && gs; }
# remote
alias gr='git remote'
alias gra='git remote add'
alias grv='git remote -v'
# rm
function grm() { git rm "${@}" && gs; }
# rebase
function grb() { git rebase "${@}" && gs; }
function grbc() { git rebase --continue "${@}" && gs; }
function grm() { git rebase $(get_default_branch) "${@}" && gs; }
function grmi() { git rebase $(get_default_branch) -i "${@}" && gs; }
function grma() { GIT_SEQUENCE_EDITOR=: git rebase $(get_default_branch) -i --autosquash "${@}" && gs; }
function gprom() { git fetch origin $(get_default_branch) && git rebase origin/$(get_default_branch) && git update-ref refs/heads/$(get_default_branch) origin/$(get_default_branch) "${@}" && gs; } # Rebase with latest remote
# reset
function gus() { git reset HEAD "${@}" && gs; }
function grhh() { git reset HEAD --hard "${@}" && gs; }
function gpristine() { git reset --hard && git clean -dfx "${@}" && gs; }
# status
function gst() { git status "${@}" && gs; }
alias gss='git status -s'
# shortlog
alias gcount='git shortlog -sn'
alias gsl='git shortlog -sn'
# show
alias gsh='git show'
# stash
function gsth() { git stash "${@}" && gs; }
alias gsthd='git stash drop'
alias gsthl='git stash list'
## 'stash push' introduced in git v2.13.2
alias gsthpu='git stash push'
alias gsthpum='git stash push -m'
## 'stash save' deprecated since git v2.16.0, alias is now push
alias gsths='git stash push'
alias gsthsm='git stash push -m'
# submodules
alias gsu='git submodule update --init --recursive'
# colors
alias ls='ls --color=auto'
alias grep='grep --color=auto'
# List directory contents
alias sl=ls
alias la='ls -AF' # Compact view, show hidden
alias ll='ls -al'
alias l='ls -a'
alias l1='ls -1'
alias lf='ls -F'
# Shortcuts to edit startup files
alias vbrc='${VISUAL:-vim} ~/.bashrc'
alias vbpf='${VISUAL:-vim} ~/.bash_profile'
alias ..='cd ..' # Go up one directory
alias cd..='cd ..' # Common misspelling for going up one directory
alias ...='cd ../..' # Go up two directories
alias ....='cd ../../..' # Go up three directories
alias -- -='cd -' # Go back
# Shell History
alias h='history'