fixup git aliases
[zsh.git] / .zsh / 35_Aliases.zsh
1 # -*- mode: sh;-*-
2
3 # default switches
4 if ls --help 2>/dev/null | grep -q GNU; then
5 alias ls='command ls -AF --color=auto'
6 elif isdarwin || isfreebsd; then
7 alias ls='command ls -AF -G'
8 fi
9
10 alias lsbig='command ls -flh *(.OL[1,10])' # display the biggest files
11 alias lssmall='command ls -Srl *(.oL[1,10])' # display the smallest files
12 alias lsnew='command ls -rl *(D.om[1,10])' # display the newest files
13 alias lsold='command ls -rtlh *(D.om[-11,-1])' # display the oldest files
14
15 alias mv='command mv -i'
16 alias mmv='noglob mmv'
17 alias cp='command cp -i'
18 alias wget='noglob wget'
19 alias cgrep='grep --color'
20 alias git='git'
21 alias rot13='tr a-zA-Z n-za-mN-ZA-M'
22 alias scp='noglob scp'
23
24 is-callable psql && alias psql='LD_PRELOAD=/lib/libreadline.so.5 psql'
25
26 alias logout='noglob logout'
27
28 # want to trace a shell function? ztrace $FUNCTIONNAME and there it goes.
29 alias ztrace='typeset -f -t'
30 alias zuntrace='typeset -f +t'
31
32 # overwrite cal
33 alias cal='cal -3'
34
35 # convenient abbreviations
36 alias c=clear
37
38 alias d='dirs -v'
39
40 alias cd/='cd /'
41 alias ..='cd ..'
42 alias ...='cd ../..'
43 alias cd..='cd ..'
44 alias cd...='cd ../..'
45 alias cd....='cd ../../..'
46 alias cd.....='cd ../../../..'
47 alias -- -='cd -'
48 for index ({1..9}) alias "$index"="cd -${index}"; unset index
49
50 alias mc='mc -d -U'
51 alias cpan='perl -MCPAN -e shell'
52 alias rh='run-help'
53
54 # No spellchecks here
55 alias man='nocorrect noglob man'
56 alias mysql='nocorrect mysql'
57 alias mkdir='nocorrect mkdir'
58 alias mv='nocorrect mv'
59
60 if [ -x /usr/bin/recode ]; then
61 alias unix2dos='recode lat1..ibmpc'
62 alias dos2unix='recode ibmpc..lat1'
63 fi
64
65 # used when you press M-? on a command line
66 alias which-command='whence -a'
67
68 # zsh function tracing
69 alias ztrace='typeset -f -t'
70 alias zuntrace='typeset -f +t'
71
72 # Make popd changes permanent without having to wait for logout
73 if zstyle -T ':ganneff:config' dirstackhandling dirpersist dirstack; then
74 alias popd="popd;dirpersiststore"
75 fi
76
77 # git related
78 # Aliases
79 alias g='git'
80
81 # branch related
82 #a# git branch base
83 alias gb='git branch'
84 #a# create a branch and switch to it
85 alias gbc='git checkout -b'
86 #a# show details for git branches
87 alias gbl='git branch -v'
88 #a# show details for git branches incl. remotes
89 alias gba='git branch -av'
90 #a# delete git branch
91 alias gbd='git branch -d'
92 #a# Move/rename a branch
93 alias gbm='git branch -m'
94
95 # add
96 #a# add changes to index
97 alias ga='git add'
98 #a# add changes, interactively choose hunks to add
99 alias gap='git add --patch'
100 #a# add changes, only files already in the indey
101 alias gau='git add --update'
102
103
104 # commit
105 #a# commit changes in git
106 alias gc='git commit -v'
107 #a# amend last git commit
108 alias gca='git commit -v --amend'
109
110 # push
111 #a# push changes
112 alias gp='git push'
113 #a# push everything to origin
114 alias gpoat='git push origin --all && git push origin --tags'
115
116 # fetch/clone/pull
117 #a# fetch and merge from another repository (pull)
118 alias gl='git pull'
119 #a# fetch and rebase from another repository
120 alias gup='git pull --rebase'
121 #a# fetch another repository
122 alias gf='git fetch'
123 #a# clone another repository
124 alias gcl='git clone'
125
126 # checkout
127 #a# checkout a branch
128 alias gco='git checkout'
129 #a# switch to the master branch
130 alias gcm='git checkout master'
131
132 # merge
133 #a# merge
134 alias gm='git merge'
135 #a# merge, but don't commit
136 alias gmn='git merge --no-ff --no-commit'
137
138 # diff
139 #a# Show changes in the working tree
140 alias gd='git diff'
141 #a# Show changes in the index
142 alias gdc='git diff --cached'
143 #a# Show logs with differences each commit introduces
144 alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
145
146 alias gcs='git show'
147
148 # log
149 #a# Show 10 latest commit logs
150 alias glg='git log --stat --max-count=10'
151 #a# Show 10 latest commit logs with a text-based graph
152 alias glgg='git log --graph --max-count=10'
153 #a# Show all commits with a text-based graph
154 alias glgga='git log --graph --decorate --all'
155
156 # various
157 #a# revert a commit
158 alias gcr='git revert'
159 #a# cherry-pick
160 alias gcp='git cherry-pick'
161
162 #a# reset HEAD
163 alias grh='git reset HEAD'
164 #a# reset HEAD discarding all changes to tracked files
165 alias grhh='git reset HEAD --hard'
166
167 #a# show working tree status
168 alias gst='git status'
169
170
171 #a# run git grep
172 alias gg='git grep'
173
174
175 # informational
176 #a# list commit count summary
177 alias gcount='git shortlog -sn'
178
179
180
181
182 # remotes
183 #a# list remotes
184 alias gr='git remote'
185 #a# list remotes including their fetch/push details
186 alias grv='git remote -v'
187 alias grmv='git remote rename'
188 alias grrm='git remote remove'
189
190 # Will cd into the top of the current repository
191 # or submodule.
192 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
193
194
195 ## global aliases. Handle with care!
196 alias -g LS='| less'
197 alias -g LL="|& less"
198 alias -g WC='| wc -l'
199 alias -g SO='| sort'
200 alias -g CD='| colordiff | less -R'
201 alias -g NE="2> /dev/null"