summaryrefslogtreecommitdiff
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
parent623b8e09f00704cb953f1b718ff9675eaffa7989 (diff)
downloaddotfiles-f1ae7aec9fd82b10abf17a19de69982f6c2f66da.tar.gz
dynamic path generation
-rw-r--r--.bash_profile1
-rw-r--r--.bashrc13
-rwxr-xr-xinstall.sh95
3 files changed, 85 insertions, 24 deletions
diff --git a/.bash_profile b/.bash_profile
index 038dfd2..5f73e6a 100644
--- a/.bash_profile
+++ b/.bash_profile
@@ -8,5 +8,6 @@ export EDITOR=nvim
export VISUAL=nvim
PATH=~/bin:$PATH
+[[ -f ~/.files ]] && source ~/.files && PATH="$DOTFILEBASE/scripts:$PATH"
[[ -f ~/.bashrc ]] && . ~/.bashrc
diff --git a/.bashrc b/.bashrc
index 109fe0a..119272d 100644
--- a/.bashrc
+++ b/.bashrc
@@ -6,15 +6,22 @@ case $- in
*) return;;
esac
-export BASH_IT_CUSTOM="/home/jonas/vimconfig"
+if [ -e ".files" ]
+then
+ source .files
+else
+ DOTFILEBASE="/home/jonas/vimconfig"
+fi
+
+export BASH_IT_CUSTOM=$DOTFILEBASE
# Path to the bash it configuration
-export BASH_IT="/home/jonas/vimconfig/bash-it"
+export BASH_IT="$DOTFILEBASE/bash-it"
# Lock and Load a custom theme file.
# Leave empty to disable theming.
# location /.bash_it/themes/
-export BASH_IT_THEME='/home/jonas/vimconfig/theme.bash'
+export BASH_IT_THEME="$DOTFILEBASE/theme.bash"
# (Advanced): Change this to the name of your remote repo if you
# cloned bash-it with a remote other than origin such as `bash-it`.
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
+