#!/usr/bin/env bash

pods_dir='~/podcasts'
# Aliases for OS X
if [[ `uname` == 'Darwin' ]]; then
    alias ls='ls -G'
    alias grep='grep --color'
    alias fgrep='fgrep --color'
    alias egrep='egrep --color'

    music_dir='~/Music'
    desktop_dir='~/Desktop'
    docs_dir='~/Documents'
else
    music_dir='~/music'
    desktop_dir='~/desktop'
    docs_dir='~/documents'

    # linux only alias
    alias push-to-player="rsync -recursive --verbose --times --modify-window=1 --delete $pods_dir/ `mount -l | awk '/podcasts/ {print $3}'`/podcast/"
fi
if [[ `uname` == 'FreeBSD' ]]; then
    alias ls='ls -G'
fi
if [[ `uname` == 'FreeBSD' ]]; then
    alias ls='ls -G'
fi

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias dir='dir --color=auto'
    alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

alias dash-v1='cd ~/code/insight-platform && ~/src/grails-1.2.2/bin/grails run-app -https -Xms800m -Xmx1000m  -XX:PermSize=200m'

# Fix vagrant up errors on Mavericks
# http://davidwalsh.name/fixing-vagrant-errors
alias fix-vagrant='sudo /Library/StartupItems/VirtualBox/VirtualBox restart'

# Some common aliases
alias ll='ls -alF'
alias df='df -h'
alias du='du -h'
alias curl='curl -s '

# Shorthand helpers
alias 644='chmod 644 '
alias 755='chmod 755 '
alias 600='chmod 600 '
alias 700='chmod 500 '
alias +x='chmod +x '
alias ..='cd .. '

# Some specialty aliases
alias meminfo='vmstat -s -S M | grep mem'
alias wget-opendir='wget -r -l 0 -c -nc -np -e robots=off --random-wait --limit-rate=800000k --reject=html,htm,index'
alias youtube-dl='youtube-dl -t '
alias rsync-win='rsync --recursive --verbose --times --modify-window=1 '
alias can-upgrade='sudo apt-get update && sudo apt-get upgrade -y '
alias can-find='aptitude search '
alias can-haz='sudo apt-get install '
alias curl-headers='curl -s -v -I '
alias take='sudo chown `whoami`:`whoami` '
alias simple-http-server='python -m SimpleHTTPServer'
alias numfiles='find . -maxdepth 1 -type f | wc -l'
alias deepgrep='find . -type f -not -name "*.swp" -not -name "*.pyc" | sed "s/$/\"/g" | sed "s/^/\"/g" | xargs grep --color '
# Show list of git branches
alias git-br='for k in `git branch|perl -pe s/^..//`; do echo -e ` git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r'

alias sync-pods="rsync --archive --verbose --compress --delete nas:~/podcasts/ $pods_dir"

# Move around to common locations
alias desktop="cd $desktop_dir"
alias podcasts="cd $pods_dir"
alias code='cd ~/code/ '
alias music="cd $music_dir"
alias documents="cd $docs_dir"

# Will add these scripts later
#alias podcasts-play-playlist="cd $pods_dir && mkpodcastplaylist ./ > pods.m3u && vlc pods.m3u 2>/dev/null &"

