Move into an external dir
[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 if zstyle -T ':ganneff:config' safemvcp false; then
16 alias mv='nocorrect command mv'
17 alias cp='nocorrect command cp'
18 else
19 alias mv='nocorrect command mv -i'
20 alias cp='nocorrect command cp -i'
21 fi
22 # Number of aliases for commands we don't want to do globbing usually
23 alias wget='noglob wget'
24 alias scp='noglob scp'
25
26 # No spellchecks for these
27 alias man='nocorrect noglob man'
28 alias mysql='nocorrect mysql'
29 alias mkdir='nocorrect mkdir'
30
31 # want to trace a shell function? ztrace $FUNCTIONNAME and there it goes.
32 #a# trace a shell function
33 alias ztrace='typeset -f -t'
34 #a# no longer trace a shell function
35 alias zuntrace='typeset -f +t'
36
37 # SSHs multisession can be controlled by giving commands to -O.
38 # Valid ones are check, forward, cancel, exit and stop, see man ssh_config
39 # for details on them
40 alias sshx="ssh -O exit"
41 alias sshc="ssh -O check"
42 alias sshf="ssh -O forward"
43 alias sshfc="ssh -O cancel"
44 alias sshs="ssh -O stop"
45
46 # overwrite cal
47 alias cal='cal -3'
48
49 # convenient abbreviations
50 alias c=clear
51 alias d='dirs -v'
52
53 # Various little cd helpers
54 alias cd/='cd /'
55 alias ..='cd ..'
56 alias ...='cd ../..'
57 alias ....='cd ../../..'
58 alias .....='cd ../../../..'
59 alias cd..='cd ..'
60 alias cd...='cd ../..'
61 alias cd....='cd ../../..'
62 alias cd.....='cd ../../../..'
63 alias -- -='cd -'
64 for index ({1..9}) alias "$index"="cd -${index}"; unset index
65
66 # various
67 alias cgrep='grep --color'
68 alias rot13='tr a-zA-Z n-za-mN-ZA-M'
69 is-command mc && alias mc='mc -d -U'
70 alias cpan='perl -MCPAN -e shell'
71 alias rh='run-help'
72
73 if [ -x /usr/bin/recode ]; then
74 alias unix2dos='recode lat1..ibmpc'
75 alias dos2unix='recode ibmpc..lat1'
76 fi
77
78 # used when you press M-? on a command line
79 alias which-command='whence -a'
80
81 # Make popd changes permanent without having to wait for logout
82 if zstyle -T ':ganneff:config' dirstackhandling dirpersist dirstack; then
83 alias popd="popd;dirpersiststore"
84 fi
85
86 # git related
87 # Aliases
88 alias g='git'
89
90 # branch related
91 #a# git branch base
92 alias gb='git branch'
93 #a# create a branch and switch to it
94 alias gbc='git checkout -b'
95 #a# show details for git branches
96 alias gbl='git branch -v'
97 #a# show details for git branches incl. remotes
98 alias gba='git branch -av'
99 #a# delete git branch
100 alias gbd='git branch -d'
101 #a# Move/rename a branch
102 alias gbm='git branch -m'
103
104 # add
105 #a# add changes to index
106 alias ga='git add'
107 #a# add changes, interactively choose hunks to add
108 alias gap='git add --patch'
109 #a# add changes, only files already in the indey
110 alias gau='git add --update'
111
112
113 # commit
114 #a# commit changes in git
115 alias gc='git commit -v'
116 #a# amend last git commit
117 alias gca='git commit -v --amend'
118 #a# fixup last git commit
119 alias gcf='git commit --fixup @'
120 #a# squash last git commit
121 alias gcs='git commit --squash @'
122 #a# fixup last commit and push it directly
123 alias gcfp='git commit --fixup @ && git push origin'
124 #a# squash last git commit and push it directly
125 alias gcsp='git commit --squash @ && git push origin'
126
127 # push
128 #a# push changes
129 alias gp='git push'
130 #a# push everything to origin
131 alias gpoat='git push origin --all && git push origin --tags'
132
133 # fetch/clone/pull
134 #a# fetch and merge from another repository (pull)
135 alias gl='git pull'
136 #a# fetch and rebase from another repository
137 alias gup='git pull --rebase'
138 #a# fetch and merge from another repository (pull), cleaning up
139 #remote-tracking references that no longer exist on the remote
140 alias glp='git pull --prune'
141 #a# fetch another repository
142 alias gf='git fetch'
143 #a# clone another repository
144 alias gcl='git clone'
145
146 # checkout
147 #a# checkout a branch
148 alias gco='git checkout'
149 #a# switch to the master branch
150 alias gcm='git checkout master'
151
152 # merge
153 #a# merge
154 alias gm='git merge'
155 #a# merge, but don't commit
156 alias gmn='git merge --no-ff --no-commit'
157
158 # diff
159 #a# Show changes in the working tree
160 alias gd='git diff'
161 #a# Show changes in the index
162 alias gdc='git diff --cached'
163 #a# Show logs with differences each commit introduces
164 alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
165
166 #a# Show last commit
167 alias gs='git show'
168
169 # log
170 #a# Show 10 latest commit logs
171 alias glg='git log --stat --max-count=10'
172 #a# Show 10 latest commit logs with a text-based graph
173 alias glgg='git log --graph --max-count=10'
174 #a# Show all commits with a text-based graph
175 alias glgga='git log --graph --decorate --all'
176
177 # various
178 #a# revert a commit
179 alias gcr='git revert'
180 #a# cherry-pick
181 alias gcp='git cherry-pick'
182
183 #a# reset HEAD
184 alias grh='git reset HEAD'
185 #a# reset HEAD discarding all changes to tracked files
186 alias grhh='git reset HEAD --hard'
187
188 #a# show working tree status
189 alias gst='git status'
190
191
192 #a# run git grep
193 alias gg='git grep'
194
195
196 # informational
197 #a# list commit count summary
198 alias gcount='git shortlog -sn'
199
200 # rebasing
201 #a# rebase
202 alias gr='git rebase'
203 #a# rebase interactive on master
204 alias gri='git rebase -i master'
205 #a# continue rebase
206 alias grc='git rebase --continue'
207 #a# abort rebase
208 alias gra='git rebase --abort'
209
210
211 # remotes
212 #a# list remotes
213 alias gre='git remote'
214 #a# list remotes including their fetch/push details
215 alias grev='git remote -v'
216 alias gremv='git remote rename'
217 alias grerm='git remote remove'
218
219 # Will cd into the top of the current repository
220 # or submodule.
221 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
222
223 ## global aliases. Handle with care!
224 alias -g LS='| less'
225 alias -g LL="|& less"
226 alias -g WC='| wc -l'
227 alias -g SO='| sort'
228 alias -g CD='| colordiff | less -R'
229 alias -g NE="2> /dev/null"