From 46b4a3f945a7a7c5fc6791b3ea6b042bbef202e3 Mon Sep 17 00:00:00 2001 From: Christian Colglazier Date: Sun, 22 Dec 2019 21:59:22 -0500 Subject: [PATCH] Moving dotfiles to independent directory --- .dotfiles/.zshrc => .zshrc | 0 scripts/install.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) rename .dotfiles/.zshrc => .zshrc (100%) create mode 100644 scripts/install.sh diff --git a/.dotfiles/.zshrc b/.zshrc similarity index 100% rename from .dotfiles/.zshrc rename to .zshrc diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..4f4bd32 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,36 @@ +#! /bin/bash + +dotdir=~/dotfiles + +# src dest sudo +files=($dotdir/.zshrc ~/ 'n' \ + ${dotdir}/alacritty/alacritty.yml ~/.config/alacritty/ 'n') + +echo Setting up dotfiles... + +# +for (( i=0; i<${#files[@]} ; i+=3 )) ; do + # Check if sudo is needed + pre='' + if [[ ${files[i+2]} == *'y'* ]]; then + pre='sudo' + fi + + destPath=${files[i+1]}$(basename "${files[i]}") + + # Check if file already exists + if [ -f $destPath ]; then + # Check if path is not a sybolic link + if ! [ -L $destPath ]; then + echo Backing up $destPath + $pre mv $destPath ${destPath}.bak + else + echo The file $destPath is already set up + continue + fi + else + echo $pre mkdir -p "$(dirname "$destPath")" + fi + echo Creating symbolic link from ${files[i]} to ${files[i+1]} + $pre ln -sf ${files[i]} ${files[i+1]} +done