dot_config/setup.sh

174 lines
5.5 KiB
Bash
Executable File

#!/bin/bash
# outcome: replace existing dot files with symlinks pointing to new version controlled files
#-------------------------------------------------------setup folder pointers and target files-------------------------------------------------------------
dir=~/dot_config
backup=~/dot_config_backup
files=".bashrc .vimrc .tmux.conf .psqlrc .gitconfig .inputrc .pspgconf"
#-------------------------------------------------install debian tooling-----------------------------------------------------------------------------------
#----------curl-----------
if [ "$(dpkg-query -W -f='${Status}' "curl" 2>/dev/null | grep -c "ok installed")" == "1" ]
then
echo "curl already installed"
else
echo "installing curl..."
apt update -q4
sudo apt install curl -y
fi
#----------vim-----------
if [ "$(dpkg-query -W -f='${Status}' "vim" 2>/dev/null | grep -c "ok installed")" == "1" ]
then
echo "vim already installed"
else
echo "installing vim..."
apt update -q4
sudo apt install vim -y
fi
#----------tmux-----------
if [ "$(dpkg-query -W -f='${Status}' "tmux" 2>/dev/null | grep -c "ok installed")" == "1" ]
then
echo "tmux already installed"
else
echo "installing tmux..."
apt update -q4
sudo apt install tmux -y
fi
#----------pspg-----------
if [ "$(dpkg-query -W -f='${Status}' "pspg" 2>/dev/null | grep -c "ok installed")" == "1" ]
then
echo "pspg already installed"
else
echo "installing pspg..."
apt update -q4
sudo apt install pspg -y
fi
#------------------------------------------------ create the resore directory if it doesn't already exist--------------------------------------------------
if [ ! -d $backup ]
then
mkdir $backup
fi
#-------------------------------------- loop through each target file, move it and create a symlink to the replacements------------------------------------
for file in $files
do
#if the file is not a symlink the just _move_ it, otherwise _copy_ the linked file
if [ ! -L $file ];
then
mv ~/$file $backup
else
# if the target file is a symlink, copy the linked file
cp $(readlink -f $file) $backup
rm $file
fi
ln -s $dir/$file ~/$file
done
#----------------------------------------------------------install go and go-powerline--------------------------------------------------------------------
# if $GOPATH is null the prompt for golang install
if [ -z "$GOPATH" ]
then
while true; do
read -p "do you want to install golang (needed for go-powerline)?" yn
case $yn in
[Yy]* )
sudo apt-get install golang -y;
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
#----------------------------------------------------------install go-powerline---------------------------------------------------------------------------
# see if this file exists, if not prompt for install
if [ ! -f ~/go/bin/powerline-go ]
then
while true; do
read -p "do you want to install go-powerline?" yn
case $yn in
[Yy]* )
go get -u github.com/justjanne/powerline-go;
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
#----------------------------------------------------------install power line fonts------------------------------------------------------------------------
if [ ! -d ~/fonts ]
then
while true; do
read -p "do you want to install powerline fonts from 'https://github.com/powerline/fonts' ?" yn
case $yn in
[Yy]* )
git clone https://github.com/powerline/fonts ~/fonts;
cd fonts;
./install.sh;
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
#----------------------------------------------------------install tmux plugin manager and tmux resurrect--------------------------------------------------
if [ ! -d ~/.tmux/plugins/tpm ]
then
while true; do
read -p "do you want to install the tmux plugin manager from 'https://github.com/tmux-plugins/tpm' ?" yn
case $yn in
[Yy]* )
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm;
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
fi
#----------------------------------------------------------see if Vundle has been cloned yet and do so-----------------------------------------------------
if [ ! -d ~/.vim/bundle ]
then
while true; do
read -p "do you want to install the Vundle plugin manager for vim from https://github.com/VundleVim/Vundle.vim.git?" yn
case $yn in
[Yy]* )
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# ask to install plugins after vundle installed
while true; do
read -p "Do you want to install the vim plugins now?" yn
case $yn in
[Yy]* ) vim +PluginInstall +qall; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
break;;
[Nn]* )
break;;
* ) echo "Please answer yes or no.";;
esac
done
fi