aboutsummaryrefslogtreecommitdiff
path: root/install.sh
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-02-23 12:26:29 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-02-23 12:26:29 +0100
commitf1ae7aec9fd82b10abf17a19de69982f6c2f66da (patch)
treea1510155550ed9b940cdff9d8d40cebd29aeeb61 /install.sh
parent623b8e09f00704cb953f1b718ff9675eaffa7989 (diff)
downloaddotfiles-f1ae7aec9fd82b10abf17a19de69982f6c2f66da.tar.gz
dynamic path generation
Diffstat (limited to 'install.sh')
-rwxr-xr-xinstall.sh95
1 files changed, 74 insertions, 21 deletions
diff --git a/install.sh b/install.sh
index 3791729..109e7c5 100755
--- a/install.sh
+++ b/install.sh
@@ -1,14 +1,10 @@
#!/bin/bash
-# Programs:
-# compton: Compositor
-# xterm fo default terminal
-
#Configs for home dir
-MODULES=(.i3 .vim .xinitrc .compton.conf .bashrc .Xresources .radare2rc .bash_profile)
+CFGS=(.i3 .vim .xinitrc .compton.conf .bashrc .Xresources .radare2rc .bash_profile)
#Configs for .config
-CFGFOLDER=(polybar powerline nvim termite twmn)
+CFGFOLDER=(polybar powerline nvim termite twmn fish)
#Scripts
SCRIPTS=()
@@ -18,18 +14,39 @@ yes_no()
{
read -p "$1 (y/[n])" inp
case $inp in
- [yY]* ) return 1;;
- * ) return 0;;
+ [yY]* ) return 0;;
+ * ) return 1;;
esac
}
+selector()
+{
+ local cnt=0
+ for i in "$@"
+ do
+ echo "$cnt) $i"
+ ((cnt=$cnt + 1))
+ done
+
+ read -p "(default=0) >" inp
+ if [[ "$inp" =~ ^-?[0-9]+\$ ]] && [ $inp -ge 0 -a $inp -le $# ]
+ then
+ return $inp
+ elif [ -z $inp ]
+ then
+ return 0
+ else
+ return -1
+ fi
+
+}
+
#1: source 2: destination
link()
{
if [ -e $2 ]
then
- yes_no "$(basename $2) exists. Overwrite?"
- if [ $? -eq 0 ]
+ if yes_no "$(basename $2) exists. Overwrite?"
then
return
fi
@@ -45,26 +62,62 @@ link()
ln -s "$1" "$2"
}
-echo Configs to install: ${MODULES[@]} ${CFGFOLDER[@]}
+
+if [ $# -gt 0 ]
+then
+ for i in "$@"
+ do
+ echo "Install $i to"
+ if [ -e $i ]
+ then
+ selector "~" "~/.config" "Custom location" "Abort"
+ case $? in
+ 0)
+ echo "~"
+ break;;
+ 1)
+ echo .config
+ break;;
+ 2)
+ echo custom
+ break;;
+ *)
+ echo Abort.
+ break;;
+ esac
+ else
+ echo $i does not exist. Skipping.
+ fi
+
+ done
+ exit 0
+fi
+
+WORKDIR=$(dirname $0)
+cd $WORKDIR
+echo Working in $WORKDIR
+echo Homedir is $HOME
+echo Available: ${CFGS[@]} ${CFGFOLDER[@]}
git submodule init
git submodule update
-for mod in ${MODULES[@]}; do
- yes_no "Install $mod?"
- #ln -s --backup $(pwd)/$mod/ ~/$mod/
- if [ $? -eq 1 ]
+for mod in "${CFGS[@]}"; do
+ if yes_no "Install $mod?"
then
- link "$(pwd)/$(dirname $0)/$mod" "$HOME/$mod"
+ link "$(pwd)/$mod" "$HOME/$mod"
fi
done
-for mod in ${CFGFOLDER[@]}; do
- #ln -s --backup $(pwd)/$mod/ ~/.config/$mod/
- yes_no "Install $mod?"
- if [ $? -eq 1 ]
+for mod in "${CFGFOLDER[@]}"; do
+ if yes_no "Install $mod?"
then
- link "$(pwd)/$(dirname $0)/$mod" "$HOME/.config/$mod"
+ link "$(pwd)/$mod" "$HOME/.config/$mod"
fi
done
+#.files is used to tell scripts where to look for the dotfiles
+if yes_no "Generate '.files'?"; then
+ echo "DOTFILEBASE=\"$(pwd)\"" > $HOME/.files
+fi
+