add script to symlink configfiles

This commit is contained in:
Thomas Preisner 2016-10-25 18:21:09 +02:00
parent d80b27d85d
commit ffda4c1ff4

30
symlink.sh Executable file
View file

@ -0,0 +1,30 @@
#!/bin/bash
# Creates symlinks from home to ~/dotfiles
#Variables
dir=~/dotfiles
olddir=~/oldConfig
files="$(find . -type f ! -path './.git/*' ! -name 'symlink.sh' -printf '%P\n')"
timestamp="$(date +%s)"
#Create oldConfig in ~
mkdir -p $olddir/$timestamp
echo "Created $olddir/$timestamp to backup existing dotfiles in ~"
#Swap dir
cd $dir
# Move any existing config-files to $olddir and then creating symlinks
for file in $files; do
echo "Backing up old configuration files"
mkdir -p $olddir/$timestamp/$(dirname $file)
mv ~/.$file $olddir/$timestamp/$file
echo "Creating symlink from homedir to $file."
mkdir -p $(dirname ~/.$file)
ln -s $dir/$file ~/.$file
echo "Done."
done