2020-05-02 23:40:45 -04:00
#!/bin/bash
2020-05-03 00:27:25 -04:00
# outcome: replace existing dot files with symlinks pointing to new version controlled files
2020-05-02 23:40:45 -04:00
2020-05-03 10:56:16 -04:00
#-------------------------------------------------------setup folder pointers and target files-------------------------------------------------------------
2020-05-02 23:40:45 -04:00
2020-05-04 13:50:15 -04:00
dir = ~/dot_config
backup = ~/dot_config_backup
2022-04-27 20:11:01 -04:00
files = ".bashrc .vimrc .tmux.conf .psqlrc .gitconfig .inputrc"
2020-05-02 23:40:45 -04:00
2021-04-15 23:31:12 -04:00
#-------------------------------------------------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
apt install curl -y
fi
#----------vim-----------
if [ " $( dpkg-query -W -f= '${Status}' "curl" 2>/dev/null | grep -c "ok installed" ) " = = "1" ]
then
echo "vim already installed"
else
echo "installing vim"
apt update -q4
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
apt install tmux -y
fi
2020-05-03 10:56:16 -04:00
#------------------------------------------------ create the resore directory if it doesn't already exist--------------------------------------------------
2020-05-02 23:40:45 -04:00
2020-05-03 01:01:25 -04:00
if [ ! -d $backup ]
2020-05-03 00:27:25 -04:00
then
2020-05-03 01:01:25 -04:00
mkdir $backup
2020-05-02 23:40:45 -04:00
fi
2020-05-03 10:56:16 -04:00
#-------------------------------------- loop through each target file, move it and create a symlink to the replacements------------------------------------
2020-05-03 00:27:25 -04:00
for file in $files
do
2020-05-03 01:01:25 -04:00
#if the file is not a symlink the just _move_ it, otherwise _copy_ the linked file
if [ ! -L $file ] ;
2020-05-03 00:27:25 -04:00
then
2020-05-03 01:01:25 -04:00
mv ~/$file $backup
else
# if the target file is a symlink, copy the linked file
cp $( readlink -f $file ) $backup
2020-05-04 13:50:15 -04:00
rm $file
2020-05-03 00:27:25 -04:00
fi
2020-05-04 13:50:15 -04:00
ln -s $dir /$file ~/$file
2020-05-03 00:27:25 -04:00
done
2020-05-03 01:39:57 -04:00
2020-12-06 22:58:11 -05:00
#----------------------------------------------------------install go and go-powerline--------------------------------------------------------------------
2021-03-12 21:53:04 -05:00
# if $GOPATH is null the prompt for golang install
2020-12-06 22:58:11 -05:00
if [ -z " $GOPATH " ]
then
while true; do
2021-03-12 21:53:04 -05:00
read -p "do you want to install golang (needed for go-powerline)?" yn
2020-12-06 22:58:11 -05:00
case $yn in
[ Yy] * )
2020-12-17 11:34:25 -05:00
sudo apt-get install golang -y;
2020-12-06 22:58:11 -05:00
break; ;
[ Nn] * )
2021-03-12 22:05:37 -05:00
break; ;
2020-12-06 22:58:11 -05:00
* ) echo "Please answer yes or no." ; ;
esac
done
fi
2020-12-17 11:34:25 -05:00
#----------------------------------------------------------install go-powerline---------------------------------------------------------------------------
2021-03-12 21:53:04 -05:00
# see if this file exists, if not prompt for install
if [ ! -f ~/go/bin/powerline-go ]
2020-12-17 11:34:25 -05:00
then
while true; do
2021-03-12 21:53:04 -05:00
read -p "do you want to install go-powerline?" yn
2020-12-17 11:34:25 -05:00
case $yn in
[ Yy] * )
go get -u github.com/justjanne/powerline-go;
break; ;
[ Nn] * )
2021-03-12 22:05:37 -05:00
break; ;
2020-12-17 11:34:25 -05:00
* ) echo "Please answer yes or no." ; ;
esac
done
fi
2021-03-12 21:53:04 -05:00
2020-12-06 22:20:08 -05:00
#----------------------------------------------------------install power line fonts------------------------------------------------------------------------
if [ ! -d ~/fonts ]
then
while true; do
2021-03-12 21:53:04 -05:00
read -p "do you want to install powerline fonts from 'https://github.com/powerline/fonts' ?" yn
2020-12-06 22:20:08 -05:00
case $yn in
[ Yy] * )
2020-12-06 23:13:30 -05:00
git clone https://github.com/powerline/fonts ~/fonts;
2020-12-06 22:20:08 -05:00
cd fonts;
./install.sh;
break; ;
[ Nn] * )
2021-03-12 22:05:37 -05:00
break; ;
2020-12-06 22:20:08 -05:00
* ) 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
2021-03-12 21:53:04 -05:00
read -p "do you want to install the tmux plugin manager from 'https://github.com/tmux-plugins/tpm' ?" yn
2020-12-06 22:20:08 -05:00
case $yn in
[ Yy] * )
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm;
break; ;
[ Nn] * )
2021-03-12 22:05:37 -05:00
break; ;
2020-12-06 22:20:08 -05:00
* ) echo "Please answer yes or no." ; ;
esac
done
fi
2020-05-03 10:56:16 -04:00
#----------------------------------------------------------see if Vundle has been cloned yet and do so-----------------------------------------------------
2021-03-12 21:53:04 -05:00
if [ ! -d ~/.vim/bundle ]
2020-05-03 01:39:57 -04:00
then
while true; do
2021-03-12 21:53:04 -05:00
read -p "do you want to install the Vundle plugin manager for vim from https://github.com/VundleVim/Vundle.vim.git?" yn
2020-05-03 01:39:57 -04:00
case $yn in
2021-03-12 21:53:04 -05:00
[ Yy] * )
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
2021-03-12 22:10:17 -05:00
# ask to install plugins after vundle installed
2021-03-12 21:53:04 -05:00
while true; do
read -p "Do you want to install the vim plugins now?" yn
case $yn in
[ Yy] * ) vim +PluginInstall +qall; break; ;
2021-03-12 22:05:37 -05:00
[ Nn] * ) break; ;
2021-03-12 21:53:04 -05:00
* ) echo "Please answer yes or no." ; ;
esac
done
2021-03-12 22:05:37 -05:00
break; ;
2021-03-12 22:10:17 -05:00
[ Nn] * )
break; ;
2020-05-03 01:39:57 -04:00
* ) echo "Please answer yes or no." ; ;
esac
done
2020-05-03 10:48:05 -04:00
fi