2012-02-01 05:37:51 +01:00
|
|
|
#
|
|
|
|
# Defines general aliases.
|
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-03-13 23:43:48 +01:00
|
|
|
setopt CORRECT # Correct commands.
|
2011-07-28 21:43:26 +02:00
|
|
|
|
2011-07-14 22:16:22 +02:00
|
|
|
# The 'ls' Family
|
2012-03-13 23:42:03 +01:00
|
|
|
if (( $+commands[dircolors] )); then
|
|
|
|
# GNU core utilities.
|
|
|
|
alias ls='ls --group-directories-first'
|
|
|
|
|
|
|
|
if zstyle -t ':omz:alias:ls' color; then
|
|
|
|
if [[ -f "$HOME/.dir_colors" ]]; then
|
|
|
|
eval $(dircolors "$HOME/.dir_colors")
|
|
|
|
fi
|
|
|
|
alias ls="$aliases[ls] --color=auto"
|
2011-06-01 08:48:26 +02:00
|
|
|
else
|
2012-03-13 23:42:03 +01:00
|
|
|
alias ls="$aliases[ls] -F"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# BSD core utilities.
|
|
|
|
if zstyle -t ':omz:alias:ls' color; then
|
2011-06-01 08:48:26 +02:00
|
|
|
export LSCOLORS="exfxcxdxbxegedabagacad"
|
2012-03-13 23:42:03 +01:00
|
|
|
alias ls="ls -G"
|
|
|
|
else
|
|
|
|
alias ls='ls -F'
|
2011-06-01 08:48:26 +02:00
|
|
|
fi
|
|
|
|
fi
|
2011-05-31 00:39:04 +02:00
|
|
|
|
2011-07-28 22:16:27 +02:00
|
|
|
alias l='ls -1A' # Show files in one column.
|
2011-06-01 08:48:26 +02:00
|
|
|
alias ll='ls -lh' # Show human readable.
|
|
|
|
alias la='ls -lhA' # Show hidden files.
|
|
|
|
alias lx='ls -lhXB' # Sort by extension.
|
|
|
|
alias lk='ls -lhSr' # Sort by size, biggest last.
|
2011-07-14 22:16:22 +02:00
|
|
|
alias lc='ls -lhtcr' # Sort by and show change time, most recent last.
|
2011-06-01 08:48:26 +02:00
|
|
|
alias lu='ls -lhtur' # Sort by and show access time, most recent last.
|
|
|
|
alias lt='ls -lhtr' # Sort by date, most recent last.
|
|
|
|
alias lm='ls -lha | more' # Pipe through 'more'.
|
|
|
|
alias lr='ls -lhR' # Recursive ls.
|
|
|
|
alias sl='ls' # I often screw this up.
|
2011-05-31 00:39:04 +02:00
|
|
|
|
|
|
|
# General
|
2011-07-28 22:16:27 +02:00
|
|
|
alias _='sudo'
|
|
|
|
alias b="$BROWSER"
|
2011-07-28 21:43:26 +02:00
|
|
|
alias cd='nocorrect cd'
|
2011-05-31 00:39:04 +02:00
|
|
|
alias cp='nocorrect cp -i'
|
2011-07-28 22:16:27 +02:00
|
|
|
alias df='df -kh'
|
|
|
|
alias du='du -kh'
|
|
|
|
alias e="$EDITOR"
|
2011-07-28 21:43:26 +02:00
|
|
|
alias find='noglob find'
|
2012-02-01 05:39:03 +01:00
|
|
|
alias fc='noglob fc'
|
2011-07-28 21:43:26 +02:00
|
|
|
alias gcc='nocorrect gcc'
|
2012-02-01 05:39:03 +01:00
|
|
|
alias history='noglob history'
|
2011-05-31 00:39:04 +02:00
|
|
|
alias ln='nocorrect ln -i'
|
2011-07-28 22:16:27 +02:00
|
|
|
alias locate='noglob locate'
|
2011-07-28 21:43:26 +02:00
|
|
|
alias man='nocorrect man'
|
2011-05-31 00:39:04 +02:00
|
|
|
alias mkdir='nocorrect mkdir -p'
|
2011-07-28 21:43:26 +02:00
|
|
|
alias mv='nocorrect mv -i'
|
2011-12-30 04:52:44 +01:00
|
|
|
alias p="$PAGER"
|
2011-07-28 22:16:27 +02:00
|
|
|
alias po='popd'
|
|
|
|
alias pu='pushd'
|
|
|
|
alias rake='noglob rake'
|
2011-07-28 21:43:26 +02:00
|
|
|
alias rm='nocorrect rm -i'
|
|
|
|
alias scp='nocorrect scp'
|
2011-05-31 00:39:04 +02:00
|
|
|
alias type='type -a'
|
2011-07-28 22:16:27 +02:00
|
|
|
|
|
|
|
# Mac OS X
|
2012-03-13 00:49:46 +01:00
|
|
|
if [[ "$OSTYPE" == darwin* ]]; then
|
|
|
|
alias o='open'
|
|
|
|
alias get='curl --continue-at - --location --progress-bar --remote-name'
|
|
|
|
else
|
|
|
|
alias o='xdg-open'
|
2011-07-28 22:16:27 +02:00
|
|
|
alias get='wget --continue --progress=bar'
|
|
|
|
|
|
|
|
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 22:16:22 +02:00
|
|
|
alias pbc='pbcopy'
|
|
|
|
alias pbp='pbpaste'
|
2009-08-28 20:14:17 +02:00
|
|
|
|
2011-07-28 22:16:27 +02:00
|
|
|
# Top
|
|
|
|
if (( $+commands[htop] )); then
|
2011-05-31 00:39:04 +02:00
|
|
|
alias top=htop
|
|
|
|
else
|
|
|
|
alias topm='top -o vsize'
|
|
|
|
alias topc='top -o cpu'
|
|
|
|
fi
|
2009-09-03 20:45:23 +02:00
|
|
|
|
2011-07-28 22:16:27 +02:00
|
|
|
# Diff/Make
|
2011-12-26 19:37:53 +01:00
|
|
|
if zstyle -t ':omz:alias:diff' color; then
|
2011-12-28 16:34:23 +01:00
|
|
|
function diff() {
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
function wdiff() {
|
2011-12-28 16:34:26 +01: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 16:34:23 +01:00
|
|
|
elif (( $+commands[git] )); then
|
2011-12-28 16:34:26 +01:00
|
|
|
git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@"
|
2011-12-28 16:34:23 +01:00
|
|
|
else
|
|
|
|
print "zsh: command not found: $0" >&2
|
|
|
|
fi
|
|
|
|
}
|
2011-06-01 08:48:26 +02:00
|
|
|
|
2011-07-28 22:16:27 +02:00
|
|
|
if (( $+commands[colormake] )); then
|
2011-06-01 08:48:26 +02:00
|
|
|
alias make='colormake'
|
2011-07-14 22:19:00 +02:00
|
|
|
compdef colormake=make
|
2011-06-01 08:48:26 +02:00
|
|
|
fi
|
|
|
|
fi
|
2009-08-28 20:14:17 +02:00
|
|
|
|
2011-07-28 22:16:27 +02:00
|
|
|
# Miscellaneous
|
2011-12-28 17:14:29 +01:00
|
|
|
(( $+commands[ack] )) && alias afind='nocorrect ack'
|
2011-07-28 22:16:27 +02:00
|
|
|
(( $+commands[ebuild] )) && alias ebuild='nocorrect ebuild'
|
|
|
|
(( $+commands[gist] )) && alias gist='nocorrect gist'
|
|
|
|
(( $+commands[heroku] )) && alias heroku='nocorrect heroku'
|
|
|
|
(( $+commands[mysql] )) && alias mysql='nocorrect mysql'
|
2010-12-24 23:20:57 +01:00
|
|
|
|