857551ea0d2e17d5d9208a5889a9fd4e8f99dfa2
[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='LANG=C git'
21 alias rot13='tr a-zA-Z n-za-mN-ZA-M'
22
23 alias psql='LANG=C LD_PRELOAD=/lib/libreadline.so.5 psql'
24
25 alias logout='noglob logout'
26
27 # want to trace a shell function? ztrace $FUNCTIONNAME and there it goes.
28 alias ztrace='typeset -f -t'
29 alias zuntrace='typeset -f +t'
30
31 # overwrite cal
32 alias cal='cal -3'
33
34 # convenient abbreviations
35 alias c=clear
36
37 alias d='dirs -v'
38
39 alias cd/='cd /'
40 alias ..='cd ..'
41 alias ...='cd ../..'
42 alias cd..='cd ..'
43 alias cd...='cd ../..'
44 alias cd....='cd ../../..'
45 alias cd.....='cd ../../../..'
46 alias -- -='cd -'
47 for index ({1..9}) alias "$index"="cd -${index}"; unset index
48
49 alias mc='mc -d -U'
50 alias cpan='perl -MCPAN -e shell'
51 alias rh='run-help'
52
53 # No spellchecks here
54 alias man='LANG=C nocorrect noglob man'
55 alias mysql='nocorrect mysql'
56 alias mkdir='nocorrect mkdir'
57 alias mv='nocorrect mv'
58
59 #global aliases. Handle with care!
60 alias -g LS='| less'
61 alias -g WC='| wc -l'
62 alias -g SO='| sort'
63 alias -g CD='| colordiff | less -R'
64
65 if [ -x /usr/bin/recode ]; then
66 alias unix2dos='recode lat1..ibmpc'
67 alias dos2unix='recode ibmpc..lat1'
68 fi
69
70 # used when you press M-? on a command line
71 alias which-command='whence -a'
72
73 # zsh function tracing
74 alias ztrace='typeset -f -t'
75 alias zuntrace='typeset -f +t'
76
77 alias gitolite_spi='ssh git@git.spi-inc.org'
78
79 # Make popd changes permanent without having to wait for logout
80 alias popd="popd;dirpersiststore"
81
82 # git related
83 # Aliases
84 alias g='git'
85 alias gst='git status'
86 alias gl='git pull'
87 alias gup='git pull --rebase'
88 alias gp='git push'
89 alias gd='git diff'
90 alias gc='git commit -v'
91 alias gca='git commit -v -a'
92 alias gco='git checkout'
93 alias gcm='git checkout master'
94 alias gr='git remote'
95 alias grv='git remote -v'
96 alias grmv='git remote rename'
97 alias grrm='git remote remove'
98 alias grset='git remote set-url'
99 alias grup='git remote update'
100 alias gb='git branch'
101 alias gba='git branch -a'
102 alias gcount='git shortlog -sn'
103 alias gcl='git config --list'
104 alias gcp='git cherry-pick'
105 alias glg='git log --stat --max-count=5'
106 alias glgg='git log --graph --max-count=5'
107 alias glgga='git log --graph --decorate --all'
108 alias gss='git status -s'
109 alias ga='git add'
110 alias gm='git merge'
111 alias grh='git reset HEAD'
112 alias grhh='git reset HEAD --hard'
113 alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
114 alias gf='git ls-files | grep'
115 alias gpoat='git push origin --all && git push origin --tags'
116
117 # Will cd into the top of the current repository
118 # or submodule.
119 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
120
121 alias gsr='git svn rebase'
122 alias gsd='git svn dcommit'
123
124 # Will return the current branch name
125 # Usage example: git pull origin $(current_branch)
126 #
127 current_branch() {
128 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
129 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
130 echo ${ref#refs/heads/}
131 }
132
133 current_repository() {
134 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
135 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
136 echo $(git remote -v | cut -d':' -f 2)
137 }
138
139 # these aliases take advantage of the previous function
140 alias ggpull='git pull origin $(current_branch)'
141 alias ggpush='git push origin $(current_branch)'
142 alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'