<file_sep>#!/bin/bash

TYPE_IGNORE=1
TYPE_LINK=2
TYPE_SPECIAL=3

ignore=( el utils backups )
special=( terminalrc sshconfig )
specialpath=( ~/.config/xfce4/terminal/terminalrc ~/.ssh/config )

DIR=~/.dotfiles

cd $DIR
for filename in *
do
    installpath=~/.${filename}
    filetype=TYPE_LINK
    specialindex=0

    # check if the file has a special installation path
    for specialname in ${special[@]}
    do
        if [[ $filename == $specialname ]]
        then
            filetype=TYPE_SPECIAL
            installpath=${specialpath[specialindex]}
            break
        fi

        true $((specialindex++))
    done

    # check if the file should be ignored
    if ! [[ $filetype == TYPE_SPECIAL ]]
    then
        for ignorename in ${ignore[@]}
        do
            if [[ $filename == $ignorename ]]
            then
                filetype=TYPE_IGNORE
            fi
        done
    fi

    # if you shouldn't ignore, and it's not already linked
    if [ $filetype != TYPE_IGNORE -a ! -L $installpath ]
    then

        # move old versions moved to backup dir
        if [ -e $installpath ]
        then
            echo ${filename} moved to ${DIR}/backups/${filename}
            mv $installpath $DIR/backups/$filename
        fi

        # create the link
        echo new link $installpath to ${DIR}/backups/${filename}
        ln -s $DIR/$filename $installpath
    fi
done

# update the submodules
git submodule update --init

# source bashrc
source ~/.bashrc


# to add new submodules use git submodule add [repo] [path to folder]
<file_sep>#!/bin/bash
# Linux startup script for disabling touchpad accel
# find devices with xinput list

# Allow computer to settle down
sleep 5

xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Device Accel Profile' -1
xinput set-prop 'SynPS/2 Synaptics TouchPad' 'Device Accel Constant Deceleration' 1

## Yoga 2 Pro 
xinput set-prop "SynPS/2 Synaptics TouchPad" "Device Accel Velocity Scaling" 8
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Finger" 35 45 0
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Coasting Speed" 5 15
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Tap Time" 120
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Tap Move" 300
xinput set-prop "SynPS/2 Synaptics TouchPad" "Synaptics Noise Cancellation" 20 20

synclient FingerHigh=46
synclient FingerLow=46
<file_sep>utils
=====

Various scripts for good times.<file_sep>#!/bin/sh

pulseaudio &
echo ****pw**** | sudo -S redshift -l 30.2848:-97.7460 &<file_sep>export JAVA_HOME=/home/kyeh/Programs/jdk1.8.0_40

alias java='/usr/lib/jvm/jdk1.8.0_40/bin/java'

shopt -s nocaseglob  # Case-insensitive globbing (pathname expansion)
shopt -s cdspell     # Auto-correct when using cd
shopt -s dotglob
shopt -s expand_aliases
shopt -s extglob

# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
for option in autocd globstar; do
        shopt -s "$option" 2> /dev/null
done

# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2 | tr ' ' '\n')" scp sftp ssh

# Better color schemes
export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \W\[\033[00m\]: '
export TERM=xterm-256color
export LSCOLORS="BaGxcxdxCxegedabagacad"
export GREP_OPTIONS='--color=auto -n'
export editor=emacs
export LD_LIBRARY_PATH=:/opt/OGRE-1.8/lib:$HOME/cs/git/Fractal-Evolution/C-Genetics/libs/AntTweakBar/lib
export PKG_CONFIG_PATH=:/opt/OGRE-1.8/lib/pkgconfig
export PATH=$PATH:$HOME/bin:$HOME/Programs/spark-1.2.0-bin-hadoop2.4/bin:$HOME/.rvm/bin:$HOME/bin/gibo:$HOME/Programs/android-studio/bin:$Home/Programs/genymotion:$Home/Programs/spark-1.2.0-bin-hadoop2.4/bin:/$HOME/Programs/idea-IC-139.224.1/bin
export GOPATH=$HOME/gocode
export SPARK_HOME=$HOME/Programs/spark-1.2.0-bin-hadoop2.4
export GEOTRELLIS_HOME=$HOME/cs/git/geotrellis/spark/target/scala-2.10
# Add RVM (Ruby Virt Machine) to PATH for scripting
# Add gibo path
# Add Android-Studio, Genymotion to path

alias ls='ls --group-directories-first --time-style=+"[%m/%d/%Y %H:%M]" --color'
alias la='ls -a --group-directories-first --time-style=+"[%m/%d/%Y %H:%M]" --color'
alias ll='ls -lh --group-directories-first --time-style=+"[%m/%d/%Y %H:%M]" --color'
alias lla='ls -alh --group-directories-first --time-style=+"[%m/%d/%Y %H:%M]" --color'
alias lal='lla'

alias emacs='emacs -nw'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

alias pwd="pwda"
alias psa="ps aux"
alias fgls='jobs'
alias fgka='for x in `jobs -p`; do kill -9 $x; done' # KILL ALL JOBS!!!!
alias xcopy='xclip -sel clip < '

alias df='df -h'      # human-readable filesizes
alias free='free -m'  # MB filesies

#######################
#                              _________________
#                     (__)    /                 \
#                     (uu)   | Keep on moving... |
#              /-------\/  --'\_________________/
#             / |     ||
#            *  ||----||
#               ^^    ^^
#######################

alias yay="echo 'yayyyyyyyy :)'"
alias yayy="echo 'yayyyyyyyyyyyyyy :)'"
alias yayyy="echo 'yayyyyyyyyyyyyyyyyyyyyyy :)'"
alias yayyyy="echo 'yayyyyyyyyyyyyyyyyyyyyyyyy!!!!!!!! :)'"
alias yayyyyy="echo 'yayyyyyyyyyyyyyyyyyyyyyyyyyyyy!!!!!!!!! :)'"
alias yayyyyyy="echo 'YAYYYYYYYYYYYYYYYYYYYYYYYYYYYY!!!!!!!!!!!! :)'"

#######################
### Deb-based Linux ###
#######################

alias apt-get='sudo apt-get'
alias apt-install='apt-get install'
alias apt-update='apt-get update'
alias apt-remove='apt-get --purge remove'
# apt-find is defined as a function below

alias apt-installed="dpkg -l | grep"  # Find installed packages relating to query
alias apt-files="dpkg -L"             # Find files provided by installed package
alias apt-ownedby="dpkg -S"           # Find the package that owns the given file


########################
### Arch-based Linux ###
########################

alias pacs="sudo pacman -S"       # Install
alias pacsy="sudo pacman -Sy"     # Install with fresh database
alias pacsyu="sudo pacman -Syu"   # Update / Upgrade
alias pacrm="sudo pacman -R"      # Remove
alias pacf="sudo pacman -Ss"      # Search for package

alias pac-get="pacsy"
alias pac-update="pacsyu"
alias pac-remove="pacrm"
alias pac-find="pacf"  

alias ya="yaourt -Sy"   # Install AUR package with fresh database
alias yas="yaourt -Ss"  # Search AUR packages

############################

# Directory History
DIRSTACKSIZE=8
alias dirs='dirs -v'
alias dh='dirs -v'
alias bd='cd $OLDPWD'
alias back='bd'
alias push='pushd'
alias pop='popd'

function cd() {
    if [ $# -eq 0 ]; then
    DIR="${HOME}"
  else
    DIR="$1"
  fi
 
  builtin pushd "${DIR}" > /dev/null
}

shopt -s cmdhist        # Combine multiline commands into one in history
shopt -s histappend
shopt -s hostcomplete
export HISTSIZE=10000
export HISTCONTROL=ignoredups  # Ignore dups, bare ls and builtin cmds
export HISTCONTROL=ignoreboth
export HISTIGNORE="&:ls:[bf]g:exit"

alias h="history | grep"  # Run desired command with !<history num>
alias f="find . | grep"
alias dopen='xdg-open'
alias odoc='dopen'

alias gitlog="git log --graph --pretty=format:'%C(yellow)%h%Creset -%Cred%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
alias gitrma="!sh -c \"git diff -z --name-only --diff-filter=D | xargs -0 git rm\""
alias gitunstage="git reset HEAD"
alias gitinfo="git remote show origin"
alias gitbranch="git branch 2> /dev/null | sed -e \"/^[^*]/d\" -e \"s/* \(.*\)/(git:\1)/\""
alias git-forcetohead="git fetch --all; git reset --hard origin/master"
alias git-unchanged="git update-index --assume-unchanged"

# Allow tab completion to propagate through sudo commands
complete -cf sudo

#################
### FUNCTIONS ###
#################

# Trim animations. If each frame occupies a different-sized portion, this will ruin offsets.
trimanim () {
    bgcolor="null"
    if [[ -z "$3" ]]; then
        bgcolor=${3}
    fi

    if [ $# -gt 1 ]; then
        convert $1 -trim +repage -layers TrimBounds -set dispose background -coalesce -scene 1 $2
        if [ bgcolor != "null" ]; then
            convert $2 -alpha off -background ${bgcolor} $2
        fi
    fi
}

# kill job by job #
fgkill () {
   jobfindcmd="sed -n -e "$1"p"
   echo $jobfindcmd
   job=`jobs -p | ${jobfindcmd}`
   kill -9 $job
}

# open nautilus in given dir (default working dir)
opendir () {
    if [ $# -gt 0 ]; then
        for dir in $@
        do
            if [ -d "$dir" ]; then
                thunar $dir >/dev/null 2>/dev/null &     
                # nautilus $dir >/dev/null 2>/dev/null &  # GNOME default file manager
            fi
        done
    else
        thunar "$PWD" & > /dev/null
        # nautilus "$PWD" & > /dev/null
    fi
}

# show diff from nth last HEAD
gitdiff () {
    distance=0
    if [ $# -gt 0 ]; then
        distance=$1
    fi

    git diff HEAD~$distance
}

# find and delete all matching regex
nuke () {
    if [ $# -gt 0 ]; then
        for reg in $@
        do
            find -name "$reg" -exec rm -f {} +
        done
    fi
}

# pwd enhanced function to show linked vs. physical dir differences.
pwda () {
    link=$(\pwd -L)
    physical=$(\pwd -P)
    if [ $link == $physical ]; then
        echo ${link}
    else
        echo "Linked:   "${link}
        echo "Physical: "${physical}
    fi
}

# up - goes up n directory levels
up(){
    local d=""
    limit=$1
    for ((i=1 ; i <= limit ; i++))
    do
        d=$d/..
    done
    d=$(echo $d | sed 's/^\///')
    if [ -z "$d" ]; then
        d=..
    fi
    cd $d
}

# Make all lines in a file unique
mkuniq () {
    if [ $# -eq 0 ]; then
        echo "Please provide a file to uniqify."
    else
        for var in $@
        do
            if [ -f $var ]; then
                perl -ne 'print unless $seen{$_}++' $1 >> $var.tmpmkuniq
                rm $var
                cat $var.tmpmkuniq >> $var
                rm $var.tmpmkuniq
            else
                echo $var is not a file.
            fi
        done
    fi
}

# Create .gitignore file for given languages
mkgibo () {
    for lang in $@
    do
        gibo $lang TextMate >> .gitignore
    done

    echo "*~" >> .gitignore
    echo "*#" >> .gitignore
    mkuniq .gitignore
}

# Self-explanatory, dude
flac2mp3 () {
    find "$1" -type f -name "*.flac" -print0 | while read -d $'\0' song

    do
        output=${song%.flac}.mp3
        avconv -i "$song" -metadata album="$1" -b 192k "$output"
    done
}

convert-anim-skip () {
    # This script will take an animated GIF and delete every other frame
    # Accepts three parameters: skip step, input file and output file
    # Usage: convert-anim-skip <skipStep> input.gif output.gif
    # To check current delay, run identify -verbose output.gif | grep Delay

    if [ $# -eq 3 ]; then
        cp $2 $3
        numframes=`convert $3 -format "%[scenes]" info: | tail -n 1`

        # delete frames
        gifsicle "$2" --unoptimize $(seq -f "#%g" 0 $1 $numframes) -O2 -o "$3"
    fi
}

# All-in-one extractor
extract () {
    if [ -f $1 ] ; then
        case $1 in
            *.tar.bz2)tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
            *.tar.gz)tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
            *.tar.xz)tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
            *.bz2)bunzip2 $1 && cd $(basename "$1" /bz2) ;;
            *.rar)unrar x $1 && cd $(basename "$1" .rar) ;;
            *.gz)gunzip $1 && cd $(basename "$1" .gz) ;;
            *.tar)tar xvf $1 && cd $(basename "$1" .tar) ;;
            *.tbz2)tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
            *.tgz)tar xvzf $1 && cd $(basename "$1" .tgz) ;;
            *.zip)unzip $1 && cd $(basename "$1" .zip) ;;
            *.Z)uncompress $1 && cd $(basename "$1" .Z) ;;
            *.7z)7z x $1 && cd $(basename "$1" .7z) ;;
            *)echo "don't know how to extract '$1'..." ;;
        esac
    else
        echo "'$1' is not a valid file!"
    fi
}

# Run command detached from terminal
detach () {
    if [ $# -gt 0 ]; then
        $@ </dev/null &>/dev/null &
    fi
}

# Mega-fancy package-finder
apt-find () {
    tmp_list=/tmp/apt_tmp_list.txt
    tmp_alist=/tmp/apt_tmp_alist.txt

    if [ -w ${tmp_list} ]; then
        rm -f ${tmp_list}
    fi

    if [ -w ${tmp_alist} ]; then
        rm -f ${tmp_alist}
    fi

    if [ -z ${1} ]; then
        echo "Please provide a package to search for."
        return
    fi

    for i in `apt-cache search ${1} | awk -F " - " '{ print $1 }'`
    do
        list=("${list[@]}" "${i}")
    done

    dpkg-query -W -f='${Package}\t${Version}\n${Description}\n\n' ${list[@]} >${tmp_list} 2>${tmp_alist}
    clear
    echo "############# Installed #################"
    echo
    grep -v "^ " ${tmp_list} | awk -F: '{printf "\033[1;32m"$1"\033[0m: "$2"\n"}'
    echo
    echo "############# Available #################"
    echo
    cat ${tmp_alist} | sed "s/dpkg-query:\ no\ packages\ found\ matching\ //g" | grep -v "No packages" | awk -F: '{printf "\033[1;31m"$1"\033[0m: "$2"\n"}'
    echo
}

export -f fgkill
export -f opendir
export -f gitdiff
export -f nuke
export -f pwda
export -f up
export -f mkuniq
export -f mkgibo
export -f flac2mp3
export -f extract
export -f apt-find
export -f convert-anim-skip
export -f cd
export -f detach

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
<file_sep>Note: minor changes have been made to solarized-definitions.el, specifically:

(base03  "#141414" "#141414" "#141414" "brightblack"   "black")  ;; Darker background
(blue    "#268bd2" "#2075c7" "#0087ff" "pink"          "pink")   ;; 8, 16-bit is now pink<file_sep>ssh-keygen -t rsa -C "<EMAIL>"
ssh-add id_rsa

# Afterwards, copy id_rsa.pub contents and add to your github account.
# Test with ssh -T git@github.com
<file_sep>sudo apt-get install pip git subversion emacs-24.3 redshift imagemagick ruby rubygems perl node libglu1-mesa-dev freeglut3-dev mesa-common-dev libglew-dev libpng-dev xclip haskell-platform dropbox autojump #multi-pipelight rails
sudo pip howdoi
sudo gem install bropages
sudo npm -g install jade html2jade

# Android Studio / GenyMotion
# intellij
# CCCP or Similar Codec Pack
# gibo
# jdk (1.7+)
# rust
# golang
<file_sep>export PS1='\[\033[0;35m\]\h\[\033[0;33m\] \W\[\033[00m\]: '
export LSCOLORS="BaGxcxdxCxegedabagacad"
alias ls='ls --color'

export editor=emacs
alias emacs='emacs -nw'
alias ..='cd ..'
alias ...='cd ...'
alias fgls='jobs'

alias gitlog="log --graph --pretty=format:'%C(yellow)%h%Creset -%Cred%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
alias gitrma="!sh -c \"git diff -z --name-only --diff-filter=D | xargs -0 git rm\""
alias gitunstage="git reset HEAD"

PATH=$PATH:$HOME/.rvm/bin:$HOME/UserProgs/android-studio/bin:$Home/UserProgs/genymotion
# Add RVM (Ruby Virt Machine) to PATH for scripting
# Add Android-Studio, Genymotion to path


extract () {
   if [ -f $1 ] ; then
       case $1 in
           *.tar.bz2)tar xvjf $1 && cd $(basename "$1" .tar.bz2) ;;
           *.tar.gz)tar xvzf $1 && cd $(basename "$1" .tar.gz) ;;
           *.tar.xz)tar Jxvf $1 && cd $(basename "$1" .tar.xz) ;;
           *.bz2)bunzip2 $1 && cd $(basename "$1" /bz2) ;;
           *.rar)unrar x $1 && cd $(basename "$1" .rar) ;;
           *.gz)gunzip $1 && cd $(basename "$1" .gz) ;;
           *.tar)tar xvf $1 && cd $(basename "$1" .tar) ;;
           *.tbz2)tar xvjf $1 && cd $(basename "$1" .tbz2) ;;
           *.tgz)tar xvzf $1 && cd $(basename "$1" .tgz) ;;
           *.zip)unzip $1 && cd $(basename "$1" .zip) ;;
           *.Z)uncompress $1 && cd $(basename "$1" .Z) ;;
           *.7z)7z x $1 && cd $(basename "$1" .7z) ;;
           *)echo "don't know how to extract '$1'..." ;;
       esac
   else
       echo "'$1' is not a valid file!"
   fi
}

export -f extract<file_sep>#!/bin/bash

# linux to windows
#sed -i 's/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/media\/kyeh\/FCA08950A0891276/C:/g' *.m3u

# windows to linux
#sed -i 's/C:/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/\.\.\/media\/kyeh\/FCA08950A0891276/g' *.m3u

# itunes removes periods from filenames, so fix that.
# itunes and banshee hate each other, so I recommend 
# 1) Open itunes and allow it to delete periods by re-adding all songs and deleting dups
# 2) Use the following sed command to fix the playlists
# 3) clear banshee and re-add all files.
# 4) Make sure banshee doesn't start adding hazardous periods in filenames.
sed -i 's/\([0-9]\{2\}\)\.\ /\1\ /g' *.m3u
