add script to symlink configfiles
This commit is contained in:
parent
d80b27d85d
commit
ffda4c1ff4
1 changed files with 30 additions and 0 deletions
30
symlink.sh
Executable file
30
symlink.sh
Executable 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue