From ef9b5655ca024010cf3f69b6a3af91d10025b6fd Mon Sep 17 00:00:00 2001 From: saibotk Date: Tue, 11 Dec 2018 21:14:43 +0100 Subject: [PATCH] Setup script will now backup existing config files --- setup.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/setup.sh b/setup.sh index bfe98c4..1dd32d4 100755 --- a/setup.sh +++ b/setup.sh @@ -2,16 +2,23 @@ commandExists() { - command -v "$1" >/dev/null 2>&1 + command -v "$1" >/dev/null 2>&1 } +backupFilesIfExists() +{ + if [ -f $1 ] || [ -h $1 ] || [ -d $1 ]; then + printf "Found $1. Backing up to $1.pre-dotfiles\n"; + mv $1 $1.pre-dotfiles; + fi +} # remove all current dotfiles echo '[INFO] Removing current dotfiles...' -rm -f ~/.zshrc -rm -f ~/.vimrc -rm -rf ~/.vim -rm -f ~/.tmux.conf -rm -rf ~/.atom +backupFilesIfExists ~/.zshrc +backupFilesIfExists ~/.vimrc +backupFilesIfExists ~/.vim +backupFilesIfExists ~/.tmux.conf +backupFilesIfExists ~/.atom # create symbolic links to dotfiles echo '[INFO] Creating symlinks to new config files in .dotfiles...'