dot_config/setup.sh

30 lines
742 B
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 00:27:25 -04:00
# setup folder pointers and target files
2020-05-02 23:40:45 -04:00
2020-05-03 00:27:25 -04:00
dir=~/linux_user_setup
olddir=~/linux_user_setup_restore
files=".bashrc .vimrc .tmux.conf .psqlrc"
2020-05-02 23:40:45 -04:00
2020-05-03 00:27:25 -04:00
# create the resore directory if it doesn't already exist
2020-05-02 23:40:45 -04:00
2020-05-03 00:27:25 -04:00
if [ ! -d $olddir ]
then
mkdir $olddir
2020-05-02 23:40:45 -04:00
fi
2020-05-03 00:27:25 -04:00
# loop through each target file, move it and create a symlink to the replacements
for file in $files
do
#if the file is already a symlink then do nothing
if [ ! -L "$file"]
then
echo "moving $file to $olddir"
mv ~/$file $olddir
echo "snapping $file to be a new symlink to version controlled file in $dir"
ln -s $dir/$file ~/$file
fi
done