#!/bin/zsh

# The following aliases vary depending on the host OS:
case "$(uname -s)" in
    Linux )
        alias ls='ls -F --color=auto'
        ;;
    Darwin )
        alias ls='ls -FG'
        ;;
esac

alias m='pine'
alias beep='echo '
alias history='fc -l 0'
alias h='history'
alias hm='h | more'
alias hrm="h -r | more"
alias hh='h -r | head'
alias ht='h 10'
alias p='ps -au'
alias tf='tail -25f'
alias l='ls -lF'
alias la='ls -laF'
alias clr='clear'
alias cls='clear'
alias d='date'
alias vi='vim '
alias v='vi'
alias vt='vi -t'
alias ta='vi -t'
alias wh='whoami'
alias new='frm -s new'
alias du='du -k'
alias df='df -k'
alias shizzle="perl -pe 's/\b(\w*[^aoeuiy])[aoeuiy]+[bcdfghjklmnpqrstvwxz]*\w\b/\1izzle/g'"

function lh () { last $@ | head; }
function ll () { ls -ltF $@ | head; }
function lu () { ls -ltuF $@ | head; }
function lum () { ls -ltuF $@ | more; }
function lut () { ls -ltuF $@ | tail; }
function lm () { ls -ltF $@ | more; }
function lt () { ls -ltF $@ | tail; }
function lk () { ls -sltF $@ | sort -nr | head; }
function lkm () { ls -sltF $@ | sort -nr | more; }
function lkt () { ls -sltF $@ | sort -nr | tail; }
function lf () { ls -lt $(find $1 -name $2 -print); }
function vif () { vi $(find $1 -name $2 -print); }
function viw () { vi $(which $1); }
function toss () { mv -f $@ ~/.trashcan; }
function xcopy () { tar cvf - -C $1 $1/* | tar xvf - -C $2; }
function checkdns () { ping $( grep nameserver /etc/resolv.conf | awk '{print $2}' | head -1); }
function has () { 
    which $1 &> /dev/null
    if [[ $? -eq 0 ]]; then
        echo 'yes'
        return 0
    else
        echo 'no'
        return 1
    fi
}

if [[ $( has pidof ) == 'no'  ]]; then
    function pidof () { ps -e -o pid,comm | grep "$1" | awk '{print $1}'; }
fi

function ssh-forget() {
    sed -i "" "/^$1,/d" ~/.ssh/known_hosts
}

function ssh-learn() {
    sed -i "" "/^$1,/d" ~/.ssh/known_hosts
    ssh-keyscan -t rsa $1 >> ~/.ssh/known_hosts
}