2012-02-01 04:37:51 +00:00
|
|
|
#
|
2012-06-03 18:02:05 +00:00
|
|
|
# Defines general aliases and functions.
|
2012-02-01 04:37:51 +00:00
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Robby Russell <robby@planetargon.com>
|
|
|
|
# Suraj N. Kurapati <sunaku@gmail.com>
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-06-03 18:02:05 +00:00
|
|
|
# Load dependencies.
|
|
|
|
omodload 'spectrum'
|
|
|
|
|
|
|
|
# Correct commands.
|
|
|
|
setopt CORRECT
|
|
|
|
|
|
|
|
# Aliases
|
|
|
|
|
|
|
|
# The 'ls' Family
|
|
|
|
if is-callable 'dircolors'; then
|
|
|
|
# GNU core utilities.
|
|
|
|
alias ls='ls --group-directories-first'
|
|
|
|
|
|
|
|
if zstyle -t ':omz:module:utility:ls' color; then
|
|
|
|
if [[ -s "$HOME/.dir_colors" ]]; then
|
|
|
|
eval "$(dircolors "$HOME/.dir_colors")"
|
|
|
|
else
|
|
|
|
eval "$(dircolors)"
|
|
|
|
fi
|
|
|
|
alias ls="$aliases[ls] --color=auto"
|
|
|
|
else
|
|
|
|
alias ls="$aliases[ls] -F"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# BSD core utilities.
|
|
|
|
if zstyle -t ':omz:module:utility:ls' color; then
|
|
|
|
export LSCOLORS="exfxcxdxbxegedabagacad"
|
|
|
|
alias ls="ls -G"
|
|
|
|
else
|
|
|
|
alias ls='ls -F'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
alias _='sudo'
|
|
|
|
alias b='${(z)BROWSER}'
|
|
|
|
alias cd='nocorrect cd'
|
|
|
|
alias cp='nocorrect cp -i'
|
|
|
|
alias df='df -kh'
|
|
|
|
alias du='du -kh'
|
|
|
|
alias e='${(z)EDITOR}'
|
|
|
|
alias find='noglob find'
|
|
|
|
alias fc='noglob fc'
|
|
|
|
alias gcc='nocorrect gcc'
|
|
|
|
alias history='noglob history'
|
|
|
|
alias ln='nocorrect ln -i'
|
|
|
|
alias locate='noglob locate'
|
|
|
|
alias man='nocorrect man'
|
|
|
|
alias mkdir='nocorrect mkdir -p'
|
|
|
|
alias mv='nocorrect mv -i'
|
|
|
|
alias p='${(z)PAGER}'
|
|
|
|
alias po='popd'
|
|
|
|
alias pu='pushd'
|
|
|
|
alias rake='noglob rake'
|
|
|
|
alias rm='nocorrect rm -i'
|
|
|
|
alias scp='nocorrect scp'
|
|
|
|
alias type='type -a'
|
|
|
|
|
|
|
|
# Mac OS X
|
|
|
|
if [[ "$OSTYPE" == darwin* ]]; then
|
|
|
|
alias o='open'
|
|
|
|
alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time'
|
|
|
|
else
|
|
|
|
alias o='xdg-open'
|
|
|
|
alias get='wget --continue --progress=bar --timestamping'
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
alias pbc='pbcopy'
|
|
|
|
alias pbp='pbpaste'
|
|
|
|
|
|
|
|
# Top
|
|
|
|
if (( $+commands[htop] )); then
|
|
|
|
alias top=htop
|
|
|
|
else
|
|
|
|
alias topm='top -o vsize'
|
|
|
|
alias topc='top -o cpu'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Miscellaneous
|
2012-06-03 18:20:37 +00:00
|
|
|
alias afind='nocorrect ack'
|
|
|
|
alias ebuild='nocorrect ebuild'
|
|
|
|
alias gist='nocorrect gist'
|
|
|
|
alias heroku='nocorrect heroku'
|
|
|
|
alias mysql='nocorrect mysql'
|
2012-06-03 18:02:05 +00:00
|
|
|
|
2011-10-12 03:13:58 +00:00
|
|
|
# Serves a directory via HTTP.
|
|
|
|
alias http-serve='python -m SimpleHTTPServer'
|
2009-08-31 22:00:38 +00:00
|
|
|
|
2012-04-11 18:13:07 +00:00
|
|
|
# Displays user owned processes status.
|
|
|
|
alias pmine='ps -U "$USER" -o pid,%cpu,%mem,command'
|
|
|
|
|
2012-06-03 18:02:05 +00:00
|
|
|
# Functions
|
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Makes a directory and changes to it.
|
2012-03-23 18:57:51 +00:00
|
|
|
function mkdcd {
|
2012-05-11 12:52:11 +00:00
|
|
|
[[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1"
|
2009-08-31 13:03:56 +00:00
|
|
|
}
|
2010-12-24 22:20:57 +00:00
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Changes to a directory and lists its contents.
|
2012-04-15 14:31:53 +00:00
|
|
|
function cdls {
|
|
|
|
builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Pushes an entry onto the directory stack and lists its contents.
|
2012-04-15 14:31:53 +00:00
|
|
|
function pushdls {
|
|
|
|
builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Pops an entry off the directory stack and lists its contents.
|
2012-04-15 14:31:53 +00:00
|
|
|
function popdls {
|
|
|
|
builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}"
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
|
|
|
|
2011-07-14 21:19:05 +00:00
|
|
|
# Prints columns 1 2 3 ... n.
|
2012-03-23 18:57:51 +00:00
|
|
|
function slit {
|
2012-04-15 00:28:28 +00:00
|
|
|
awk "{ print ${(j:,:):-\$${^@}} }"
|
2011-07-14 21:19:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# Finds files and executes a command on them.
|
2012-03-23 18:57:51 +00:00
|
|
|
function find-exec {
|
2011-07-14 21:19:05 +00:00
|
|
|
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
|
2011-05-30 22:39:04 +00:00
|
|
|
}
|
|
|
|
|