#!env bash
DOTFILE_DIR="$(pwd)"

pushd ~

sudo apt-get update
sudo apt-get install vim tmux git fluxbox aptitude default-jdk default-jdk-doc fontconfig apt-file thefuck libxft-dev python-setuptools vlc keepassx tree unison lilypond  htop synaptic dmsetup suckless-tools
sudo apt-file update
mkdir ~/projects ~/programs ~/temp
cd "$DOTFILE_DIR"
cp -r bin .fonts .tmux.conf .vimrc .vim .bash_aliases .gitconfig .screenrc .Xdefaults .config .gradle .xinitrc .wdiwtlt.properties .wdiwtlt.cli.properties ~
cat .bashrc >> ~/.bashrc

# VIM
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
cd ~/.vim/bundle
git clone https://github.com/ctrlpvim/ctrlp.vim.git
#git clone https://github.com/leafgarland/typescript-vim.git
git clone https://github.com/zah/nim.vim.git
git clone https://github.com/tpope/vim-fugitive.git
git clone https://github.com/isRuslan/vim-es6.git
git clone https://github.com/airblade/vim-gitgutter.git
git clone https://github.com/akhaku/vim-java-unused-imports.git
ln -s /usr/share/lilypond/2.18.2/vim lilypond.vim

# Setup ST
git clone http://git.suckless.org/st programs/st
cd ~/programs/st
cp "$DOTFILE_DIR/st/*" .
cp config.normal.h config.h && make && sudo make install
cp config.large.h config.h && make && sudo cp st /usr/local/bin/st-large
cp config.small.h config.h && make && sudo cp st /usr/local/bin/st-small

# Setup Java, Groovy & Gradle
cd ~/temp
wget https://dl.bintray.com/groovy/maven/apache-groovy-sdk-2.4.7.zip
wget https://services.gradle.org/distributions/gradle-2.12-all.zip
cd ~/programs
unzip ~/temp/apache-groovy-sdk-2.4.7.zip
unzip ~/temp/gradle-2.12-all.zip
rm ~/temp/apache-groovy-sdk-2.4.7.zip
rm ~/temp/gradle-2.12-all.zip
ln -s groovy-2.4.7 groovy
ln -s gradle-2.12 gradle

echo 'export JAVA_HOME=/usr/lib/jvm/default-java' >> ~/.profile
echo 'export GROOVY_HOME=$HOME/programs/groovy' >> ~/.profile
echo 'export GRADLE_HOME=$HOME/programs/gradle' >> ~/.profile
echo 'export PATH="$PATH:$GROOVY_HOME/bin:$GRADLE_HOME/bin"' >> ~/.profile

# Setup Nim
curl https://nim-lang.org/choosenim/init.sh -sSf | sh
chmod +x ~/.choosenim/toolchains/*/bin/
echo 'export PATH="$PATH:$HOME/.nimble/bin"' >> ~/.profile
export PATH="$PATH:$HOME/.nimble/bin"

source ~/.profile

# WDIWTLT
cd ~/projects
git clone _git@git.jdb-labs.com:jdb/util-classes
cd util-classes
git checkout 4.4
gradle install clean
cd ..
git clone _git@git.jdb-labs.com:jdb/wdiwtlt
cd wdiwtlt
gradle clean assembleDist
cd ~/programs
tar xf ~/projects/wdiwtlt/cli/build/distributions/*.tar
mv wdiwtlt-* wdiwtlt
chmod +x
ln -s wdiwtlt/bin/wdiwtlt-cli ~/bin/wdiwtlt

popd
