48 lines
1.7 KiB
Bash
Executable File
48 lines
1.7 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"
|
|
|
|
#------------------------------------------------ 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
|
|
|
|
#----------------------------------------------------------see if Vundle has been cloned yet and do so-----------------------------------------------------
|
|
|
|
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
|
|
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"
|