From 02fa0a45766c75d17e9e455b56f81f5c8dd26ad6 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 6 Jan 2017 16:23:55 -0500 Subject: [PATCH] bootstrap: link topic parent dotfiles --- bootstrap | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/bootstrap b/bootstrap index c02ab80c..40560c05 100755 --- a/bootstrap +++ b/bootstrap @@ -69,6 +69,20 @@ _link() { fi } +_linkall() { + local file="$1" + if [[ -d "$file" && "${file##*/}" == .@(config|local) ]]; then + for subfile in "$file"/*; do + base="$HOME/${file##*/}/" + [[ -d $base ]] || _run mkdir -p "$base" + _link "$subfile" "$base" + done + elif [[ -e $file ]]; then + _link "$file" "$HOME/" + fi +} + + ## install=1 link=1 @@ -119,25 +133,23 @@ for topic in ${@:-$(find "$ENABLED_DIR" -maxdepth 1 -type l)}; do [[ -d $topic ]] || continue tpath="$CWD/$topic" - tname="$(basename $(dirname $tpath))_${tpath##*/}" + tparentpath="$(dirname $tpath)" + tname="${tparentpath##*/}_${tpath##*/}" echo -e "${green}${tname//_//}${nc}" # Link binaries for bin in $tpath/bin/*; do [[ "$link" && -x "$bin" ]] && _link "$bin" "$HOME/.bin/" done - # Symlink dotfiles from topic directories (2 levels deep) if [[ $link ]]; then + # Symlink dotfiles from topic parent directory + for file in "$tparentpath"/.[a-zA-Z]*; do + _linkall "$file" + done + + # Symlink dotfiles from topic directories (2 levels deep) for file in "$tpath"/.[a-zA-Z]*; do - if [[ -d $file && "${file##*/}" == .config ]]; then - for subfile in "$file"/*; do - base="$HOME/${file##*/}/" - [[ -d $base ]] || _run mkdir -p "$base" - _link "$subfile" "$base" - done - elif [[ -e $file ]]; then - _link "$file" "$HOME/" - fi + _linkall "$file" done fi