summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-06-05 15:50:02 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-06-05 15:50:02 +0200
commit5ab1bb15694c7e7dd3db1cf82ca98cffeaa3f37b (patch)
tree82559781eb8621d474ad3893559f6d833dc71406
parent873442815ad9030dbf9694dbdd1a23685317f74b (diff)
downloaddotfiles-5ab1bb15694c7e7dd3db1cf82ca98cffeaa3f37b.tar.gz
Improved install script
-rwxr-xr-xinstall.sh49
1 files 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