1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 21:58:00 +00:00
prezto/alias.zsh

142 lines
3.7 KiB
Bash
Raw Normal View History

2012-02-01 04:37:51 +00:00
#
# Defines general aliases.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
2012-03-13 22:43:48 +00:00
setopt CORRECT # Correct commands.
2011-07-28 19:43:26 +00:00
2011-07-14 20:16:22 +00:00
# The 'ls' Family
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"
else
alias ls="$aliases[ls] -F"
fi
else
# BSD core utilities.
if zstyle -t ':omz:alias:ls' color; then
export LSCOLORS="exfxcxdxbxegedabagacad"
alias ls="ls -G"
else
alias ls='ls -F'
fi
fi
2012-03-13 23:05:10 +00: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.
# General
2011-07-28 20:16:27 +00:00
alias _='sudo'
alias b="$BROWSER"
2011-07-28 19:43:26 +00:00
alias cd='nocorrect cd'
alias cp='nocorrect cp -i'
2011-07-28 20:16:27 +00:00
alias df='df -kh'
alias du='du -kh'
alias e="$EDITOR"
2011-07-28 19:43:26 +00:00
alias find='noglob find'
2012-02-01 04:39:03 +00:00
alias fc='noglob fc'
2011-07-28 19:43:26 +00:00
alias gcc='nocorrect gcc'
2012-02-01 04:39:03 +00:00
alias history='noglob history'
alias ln='nocorrect ln -i'
2011-07-28 20:16:27 +00:00
alias locate='noglob locate'
2011-07-28 19:43:26 +00:00
alias man='nocorrect man'
alias mkdir='nocorrect mkdir -p'
2011-07-28 19:43:26 +00:00
alias mv='nocorrect mv -i'
alias p="$PAGER"
2011-07-28 20:16:27 +00:00
alias po='popd'
alias pu='pushd'
alias rake='noglob rake'
2011-07-28 19:43:26 +00:00
alias rm='nocorrect rm -i'
alias scp='nocorrect scp'
alias type='type -a'
2011-07-28 20:16:27 +00:00
# Mac OS X
2012-03-12 23:49:46 +00: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 20:16:27 +00: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 20:16:22 +00:00
alias pbc='pbcopy'
alias pbp='pbpaste'
2011-07-28 20:16:27 +00:00
# Top
if (( $+commands[htop] )); then
alias top=htop
else
alias topm='top -o vsize'
alias topc='top -o cpu'
fi
2009-09-03 18:45:23 +00:00
2011-07-28 20:16:27 +00:00
# Diff/Make
if zstyle -t ':omz:alias:diff' color; then
function diff {
2011-12-28 15:34:23 +00: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
}
function wdiff {
2011-12-28 15:34:26 +00: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 15:34:23 +00:00
elif (( $+commands[git] )); then
2011-12-28 15:34:26 +00:00
git --no-pager diff --color=auto --no-ext-diff --no-index --color-words "$@"
2011-12-28 15:34:23 +00:00
else
print "zsh: command not found: $0" >&2
fi
}
2011-07-28 20:16:27 +00:00
if (( $+commands[colormake] )); then
alias make='colormake'
compdef colormake=make
fi
fi
2011-07-28 20:16:27 +00:00
# Miscellaneous
2011-12-28 16:14:29 +00:00
(( $+commands[ack] )) && alias afind='nocorrect ack'
2011-07-28 20:16:27 +00: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'