dot_config/setup.sh

86 lines
2.9 KiB
Bash
Raw Normal View History

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
dir=~/dot_config
backup=~/dot_config_backup
2020-05-17 00:05:00 -04:00
files=".bashrc .vimrc .tmux.conf .psqlrc .gitconfig"
2020-05-02 23:40:45 -04:00
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
if [ ! -d $backup ]
2020-05-03 00:27:25 -04:00
then
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
#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
mv ~/$file $backup
else
# if the target file is a symlink, copy the linked file
cp $(readlink -f $file) $backup
rm $file
2020-05-03 00:27:25 -04:00
fi
ln -s $dir/$file ~/$file
2020-05-03 00:27:25 -04:00
done
2020-05-03 01:39:57 -04:00
#----------------------------------------------------------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;
cd fonts;
./install.sh;
break;;
[Nn]* )
exit;;
* ) 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]* )
exit;;
* ) 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-----------------------------------------------------
2020-05-03 01:39:57 -04:00
if [ ! -d ~/.vim ]
then
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
while true; do
read -p "Do you want to install the vim plugins now?" yn
case $yn in
[Yy]* ) vim +PluginInstall +qall; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
2020-05-03 10:48:05 -04:00
fi
echo "you may need to run vim and execute :PluginInstall to sync packages with the new .vimrc, or \"vim +PluginInstall +qall\" from the command line"