2012-01-31 23:37:51 -05:00
|
|
|
#
|
|
|
|
# Defines general aliases.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-04-04 10:21:47 -04:00
|
|
|
# Load dependencies.
|
|
|
|
omodload 'spectrum'
|
|
|
|
|
2012-03-13 18:43:48 -04:00
|
|
|
setopt CORRECT # Correct commands.
|
2011-07-28 15:43:26 -04:00
|
|
|
|
2011-07-14 16:16:22 -04:00
|
|
|
# The 'ls' Family
|
2012-04-10 23:18:26 -04:00
|
|
|
if is-callable 'dircolors'; then
|
2012-03-13 18:42:03 -04:00
|
|
|
# GNU core utilities.
|
|
|
|
alias ls='ls --group-directories-first'
|
|
|
|
|
|
|
|
if zstyle -t ':omz:alias:ls' color; then
|
2012-04-16 14:21:29 -04:00
|
|
|
if [[ -s "$HOME/.dir_colors" ]]; then
|
2012-04-02 11:25:22 -04:00
|
|
|
eval "$(dircolors "$HOME/.dir_colors")"
|
|
|
|
else
|
|
|
|
eval "$(dircolors)"
|
2012-03-13 18:42:03 -04:00
|
|
|
fi
|
|
|
|
alias ls="$aliases[ls] --color=auto"
|
2011-06-01 02:48:26 -04:00
|
|
|
else
|
2012-03-13 18:42:03 -04:00
|
|
|
alias ls="$aliases[ls] -F"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# BSD core utilities.
|
|
|
|
if zstyle -t ':omz:alias:ls' color; then
|
2011-06-01 02:48:26 -04:00
|
|
|
export LSCOLORS="exfxcxdxbxegedabagacad"
|
2012-03-13 18:42:03 -04:00
|
|
|
alias ls="ls -G"
|
|
|
|
else
|
|
|
|
alias ls='ls -F'
|
2011-06-01 02:48:26 -04:00
|
|
|
fi
|
|
|
|
fi
|
2011-05-30 18:39:04 -04:00
|
|
|
|
2012-03-13 19:05:10 -04:00
|
|
|
alias l='ls -1A' # List in one column.
|
|
|
|
alias ll='ls -lh' # List human readable sizes.
|
|
|
|
alias lr='ll -R' # List recursively.
|
|
|
|
alias la='ll -A' # List hidden files.
|
|
|
|
alias lp='la | "$PAGER"' # List through pager.
|
|
|
|
alias lx='ll -XB' # List sorted by extension.
|
|
|
|
alias lk='ll -Sr' # List sorted by size, largest last.
|
|
|
|
alias lt='ll -tr' # List sorted by date, most recent last.
|
|
|
|
alias lc='lt -c' # List sorted by date, most recent last, show change time.
|
|
|
|
alias lu='lt -u' # List sorted by date, most recent last, show access time.
|
|
|
|
alias sl='ls' # I often screw this up.
|
2011-05-30 18:39:04 -04:00
|
|
|
|
|
|
|
# General
|
2011-07-28 16:16:27 -04:00
|
|
|
alias _='sudo'
|
2012-03-29 13:33:20 -04:00
|
|
|
alias b='${(z)BROWSER}'
|
2011-07-28 15:43:26 -04:00
|
|
|
alias cd='nocorrect cd'
|
2011-05-30 18:39:04 -04:00
|
|
|
alias cp='nocorrect cp -i'
|
2011-07-28 16:16:27 -04:00
|
|
|
alias df='df -kh'
|
|
|
|
alias du='du -kh'
|
2012-03-29 13:33:20 -04:00
|
|
|
alias e='${(z)EDITOR}'
|
2011-07-28 15:43:26 -04:00
|
|
|
alias find='noglob find'
|
2012-01-31 23:39:03 -05:00
|
|
|
alias fc='noglob fc'
|
2011-07-28 15:43:26 -04:00
|
|
|
alias gcc='nocorrect gcc'
|
2012-01-31 23:39:03 -05:00
|
|
|
alias history='noglob history'
|
2011-05-30 18:39:04 -04:00
|
|
|
alias ln='nocorrect ln -i'
|
2011-07-28 16:16:27 -04:00
|
|
|
alias locate='noglob locate'
|
2011-07-28 15:43:26 -04:00
|
|
|
alias man='nocorrect man'
|
2011-05-30 18:39:04 -04:00
|
|
|
alias mkdir='nocorrect mkdir -p'
|
2011-07-28 15:43:26 -04:00
|
|
|
alias mv='nocorrect mv -i'
|
2012-03-29 13:33:20 -04:00
|
|
|
alias p='${(z)PAGER}'
|
2011-07-28 16:16:27 -04:00
|
|
|
alias po='popd'
|
|
|
|
alias pu='pushd'
|
|
|
|
alias rake='noglob rake'
|
2011-07-28 15:43:26 -04:00
|
|
|
alias rm='nocorrect rm -i'
|
|
|
|
alias scp='nocorrect scp'
|
2011-05-30 18:39:04 -04:00
|
|
|
alias type='type -a'
|
2011-07-28 16:16:27 -04:00
|
|
|
|
|
|
|
# Mac OS X
|
2012-03-12 19:49:46 -04:00
|
|
|
if [[ "$OSTYPE" == darwin* ]]; then
|
|
|
|
alias o='open'
|
2012-04-22 10:39:43 -04:00
|
|
|
alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time'
|
2012-03-12 19:49:46 -04:00
|
|
|
else
|
|
|
|
alias o='xdg-open'
|
2012-04-22 10:39:43 -04:00
|
|
|
alias get='wget --continue --progress=bar --timestamping'
|
2011-07-28 16:16:27 -04:00
|
|
|
|
|
|
|
if (( $+commands[xclip] )); then
|
|
|
|
alias pbcopy='xclip -selection clipboard -in'
|
|
|
|
alias pbpaste='xclip -selection clipboard -out'
|
|
|
|
fi
|
|
|
|
|
|
|
|
if (( $+commands[xsel] )); then
|
|
|
|
alias pbcopy='xsel --clipboard --input'
|
|
|
|
alias pbpaste='xsel --clipboard --output'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2011-07-14 16:16:22 -04:00
|
|
|
alias pbc='pbcopy'
|
|
|
|
alias pbp='pbpaste'
|
2009-08-28 14:14:17 -04:00
|
|
|
|
2011-07-28 16:16:27 -04:00
|
|
|
# Top
|
|
|
|
if (( $+commands[htop] )); then
|
2011-05-30 18:39:04 -04:00
|
|
|
alias top=htop
|
|
|
|
else
|
|
|
|
alias topm='top -o vsize'
|
|
|
|
alias topc='top -o cpu'
|
|
|
|
fi
|
2009-09-03 14:45:23 -04:00
|
|
|
|
2011-07-28 16:16:27 -04:00
|
|
|
# Diff/Make
|
2011-12-26 13:37:53 -05:00
|
|
|
if zstyle -t ':omz:alias:diff' color; then
|
2012-03-23 14:57:51 -04:00
|
|
|
function diff {
|
2011-12-28 10:34:23 -05:00
|
|
|
if (( $+commands[colordiff] )); then
|
|
|
|
"$commands[diff]" --unified "$@" | colordiff --difftype diffu
|
|
|
|
elif (( $+commands[git] )); then
|
|
|
|
git --no-pager diff --color=auto --no-ext-diff --no-index "$@"
|
|
|
|
else
|
|
|
|
"$commands[diff]" --unified "$@"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-03-23 14:57:51 -04:00
|
|
|
function wdiff {
|
2011-12-28 10:34:26 -05:00
|
|
|
if (( $+commands[wdiff] )); then
|
|
|
|
"$commands[wdiff]" \
|
|
|
|
--avoid-wraps \
|
|
|
|
--start-delete="$(print -n $FG[red])" \
|
|
|
|
--end-delete="$(print -n $FG[none])" \
|
|
|
|
--start-insert="$(print -n $FG[green])" \
|
|
|
|
--end-insert="$(print -n $FG[none])" \
|
|
|
|
"$@" \
|
|
|
|
| sed 's/^\(@@\( [+-][[:digit:]]*,[[:digit:]]*\)\{2\} @@\)$/;5;6m\10m/g'
|
2011-12-28 10:34:23 -05:00
|
|
|
elif (( $+commands[git] )); then
|
2011-12-28 10:34:26 -05:00
|
|
|
git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@"
|
2011-12-28 10:34:23 -05:00
|
|
|
else
|
|
|
|
print "zsh: command not found: $0" >&2
|
|
|
|
fi
|
|
|
|
}
|
2011-06-01 02:48:26 -04:00
|
|
|
|
2011-07-28 16:16:27 -04:00
|
|
|
if (( $+commands[colormake] )); then
|
2011-06-01 02:48:26 -04:00
|
|
|
alias make='colormake'
|
2012-04-03 20:14:08 -04:00
|
|
|
compdef colormake=make 2> /dev/null
|
2011-06-01 02:48:26 -04:00
|
|
|
fi
|
|
|
|
fi
|
2009-08-28 14:14:17 -04:00
|
|
|
|
2011-07-28 16:16:27 -04:00
|
|
|
# Miscellaneous
|
2012-04-02 19:30:04 -04:00
|
|
|
if (( $+commands[ack] )) alias afind='nocorrect ack'
|
|
|
|
if (( $+commands[ebuild] )) alias ebuild='nocorrect ebuild'
|
|
|
|
if (( $+commands[gist] )) alias gist='nocorrect gist'
|
|
|
|
if (( $+commands[heroku] )) alias heroku='nocorrect heroku'
|
|
|
|
if (( $+commands[mysql] )) alias mysql='nocorrect mysql'
|
2010-12-24 17:20:57 -05:00
|
|
|
|