use setvar and respect settings as given in zshenv.local
[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 if zstyle -T ':ganneff:config' dirpersiststore && is434; then
81 alias popd="popd;dirpersiststore"
82 fi
83
84 # git related
85 # Aliases
86 alias g='git'
87 alias gst='git status'
88 alias gl='git pull'
89 alias gup='git pull --rebase'
90 alias gp='git push'
91 alias gd='git diff'
92 alias gc='git commit -v'
93 alias gca='git commit -v -a'
94 alias gco='git checkout'
95 alias gcm='git checkout master'
96 alias gr='git remote'
97 alias grv='git remote -v'
98 alias grmv='git remote rename'
99 alias grrm='git remote remove'
100 alias grset='git remote set-url'
101 alias grup='git remote update'
102 alias gb='git branch'
103 alias gba='git branch -a'
104 alias gcount='git shortlog -sn'
105 alias gcl='git config --list'
106 alias gcp='git cherry-pick'
107 alias glg='git log --stat --max-count=5'
108 alias glgg='git log --graph --max-count=5'
109 alias glgga='git log --graph --decorate --all'
110 alias gss='git status -s'
111 alias ga='git add'
112 alias gm='git merge'
113 alias grh='git reset HEAD'
114 alias grhh='git reset HEAD --hard'
115 alias gwc='git whatchanged -p --abbrev-commit --pretty=medium'
116 alias gf='git ls-files | grep'
117 alias gpoat='git push origin --all && git push origin --tags'
118
119 # Will cd into the top of the current repository
120 # or submodule.
121 alias grt='cd $(git rev-parse --show-toplevel || echo ".")'
122
123 alias gsr='git svn rebase'
124 alias gsd='git svn dcommit'
125
126 # Will return the current branch name
127 # Usage example: git pull origin $(current_branch)
128 #
129 current_branch() {
130 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
131 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
132 echo ${ref#refs/heads/}
133 }
134
135 current_repository() {
136 ref=$(git symbolic-ref HEAD 2> /dev/null) || \
137 ref=$(git rev-parse --short HEAD 2> /dev/null) || return
138 echo $(git remote -v | cut -d':' -f 2)
139 }
140
141 # these aliases take advantage of the previous function
142 alias ggpull='git pull origin $(current_branch)'
143 alias ggpush='git push origin $(current_branch)'
144 alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'