From 5ab1bb15694c7e7dd3db1cf82ca98cffeaa3f37b Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Wed, 5 Jun 2019 15:50:02 +0200 Subject: Improved install script --- install.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 45bc38b..02ad60b 100755 --- a/install.sh +++ b/install.sh @@ -10,19 +10,58 @@ MODULES=(.i3 .vim .xinitrc .compton.conf .bashrc .Xresources) #Configs for .config CFGFOLDER=(polybar powerline nvim) +#1: message +yes_no() +{ + read -p "$1 (y/[n])" inp + case $inp in + [yY]* ) return 1;; + * ) return 0;; + esac +} + +#1: source 2: destination +link() +{ + if [ -e $2 ] + then + yes_no "$(basename $2) exists. Overwrite?" + if [ $? -eq 0 ] + then + return + fi + + if [ -d $2 ] + then + rm -R $2 + else + rm $2 + fi + fi + + ln -s "$1" "$2" +} + echo Configs to install: ${MODULES[@]} ${CFGFOLDER[@]} git submodule init git submodule update for mod in ${MODULES[@]}; do - echo Linking $mod - mv ~/$mod ~/$mod.old - ln -s $(pwd)/$mod ~/$mod + yes_no "Install $mod?" + #ln -s --backup $(pwd)/$mod/ ~/$mod/ + if [ $? -eq 1 ] + then + link "$(pwd)/$(dirname $0)/$mod" "$HOME/$mod" + fi done for mod in ${CFGFOLDER[@]}; do - mv ~/.config/$mod ~/.config/$mod.old - ln -s $(pwd)/$mod ~/.config/$mod + #ln -s --backup $(pwd)/$mod/ ~/.config/$mod/ + yes_no "Install $mod?" + if [ $? -eq 1 ] + then + link "$(pwd)/$(dirname $0)/$mod" "$HOME/.config/$mod" + fi done -- cgit v1.2.3