Separate linux/mac aliases & add functions

This commit is contained in:
Henrik Lissner 2013-10-26 11:49:13 -04:00
parent fcbb5763fd
commit eee9efe870

View file

@ -15,60 +15,81 @@ if [ -e /Applications/love.app ]; then
fi fi
# Shell conveniences # Shell conveniences
if is_mac; then
alias ls='ls -G'
else
alias ls='ls --color'
fi
alias sudo='sudo '
alias l='ls -1' alias l='ls -1'
alias ll='ls -l' alias ll='ls -l'
alias la='ls -la' alias la='ls -la'
alias l.='ls -Ad .*' alias l.='ls -Ad .*'
alias du='du -h -d 1' alias du='du -h -d 1'
alias q='exit' alias q='exit'
alias sha1='openssl sha1' alias sha1='openssl sha1'
alias mkdir='mkdir -pv' alias mkdir='mkdir -pv'
# Resume download if possible
alias wget='wget -c'
alias header='curl -I' alias header='curl -I'
# Resume download if possible
alias wget='wget -c'
# Lets us sudo aliases
alias sudo='sudo '
if is_linux; then if is_linux; then
alias ls='ls --color'
# iptables # iptables
alias ipt='sudo iptables' alias ipt='sudo iptables'
function v {
if [ $# -eq 0 ]; then
vim .
else
vim "$@"
fi
}
elif is_mac; then elif is_mac; then
alias ls='ls -G'
alias b='brew' alias b='brew'
alias brewp='cd `brew --prefix`' alias brewp='cd `brew --prefix`'
alias ql='quicklook' alias ql='quicklook'
fi
# vim function o {
if [[ ! -n $SSH_CLIENT ]]; then if [ $# -eq 0 ]; then
if command_exists mvim; then open .
alias v='mvim'
else else
alias v='gvim' open "$@"
fi fi
else }
alias v='vim'
function v {
if [ $# -eq 0 ]; then
mvim .
else
mvim "$@"
fi
}
fi fi
# Text-editing niceties # Make a directory and change to it
function mkd {
mkdir "$@" && cd "$@"
}
# Replace # Meant for string search-and-replace via stdin
function repl { function repl {
sed $3 -e "s/${1/\//\\\/}/${2/\//\\\/}/g" sed $3 -e "s/${1/\//\\\/}/${2/\//\\\/}/g"
} }
if command_exists "ag"; then if command_exists "ag"; then
# Project-wide search 'n replace using the_silver_searcher: # Project-wide search 'n replace using the_silver_searcher:
# https://github.com/ggreer/the_silver_searcher # https://github.com/ggreer/the_silver_searcher
function agr { function agr {
ag -l "$1" | xargs repl "$1" "$2" -i ag -l "$1" | xargs repl "$1" "$2" -i
ag "$2" ag "$2"
} }
fi fi
# vim:set ft=zsh: # vim:set ft=zsh: