From b8aeeccc86f1c503fc77e6c69cd1648947bddcdf Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 16 Dec 2016 18:33:59 -0500 Subject: [PATCH] Add $ENABLED_DIR and move $DOTFILES --- bootstrap | 9 ++++----- shell/common.sh | 8 +++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bootstrap b/bootstrap index 2cc57902..3429cac3 100755 --- a/bootstrap +++ b/bootstrap @@ -19,8 +19,7 @@ # -n Don't overwrite conflicts (no prompts set -e -DOTFILES=$(cd $(dirname $0) && pwd -P) -source "$DOTFILES/shell/common.sh" +source "$(cd $(dirname $0) && pwd -P)/shell/common.sh" shopt -s nullglob # @@ -88,7 +87,7 @@ shift $((OPTIND-1)) # [[ -d ~/.bin ]] || _run mkdir -p ~/.bin PATH="$DOTFILES/.bin:$PATH" -for topic in ${@:-$(find "$DOTFILES/.enabled.d" -maxdepth 1 -type l)}; do +for topic in ${@:-$(find "$ENABLED_DIR" -maxdepth 1 -type l)}; do [[ -d $topic ]] || continue tpath=$(realpath "$topic") @@ -100,11 +99,11 @@ for topic in ${@:-$(find "$DOTFILES/.enabled.d" -maxdepth 1 -type l)}; do done # Link topic to .enabled.d - if [[ -h "$DOTFILES/.enabled.d/$tname" ]]; then + if [[ -h "$ENABLED_DIR/$tname" ]]; then [[ "$update" && -x $tpath/update ]] && _run "$tpath/update" else # Register topic as 'enabled' - _run ln -svf "$tpath" "$DOTFILES/.enabled.d/$tname" + _run ln -svf "$tpath" "$ENABLED_DIR/$tname" # Run install script [[ "$install" && -x $tpath/install ]] && _run "$tpath/install" diff --git a/shell/common.sh b/shell/common.sh index 1e4fb962..bf5a1a88 100644 --- a/shell/common.sh +++ b/shell/common.sh @@ -1,4 +1,6 @@ -CACHE_DIR="$DOTFILES/shell/zsh/cache" +DOTFILES="$HOME/.dotfiles" +CACHE_DIR="$HOME/.cache/${ZSH_NAME:-sh}" +ENABLED_DIR="$DOTFILES/.enabled.d" is-callable() { command -v "$1" >/dev/null; } is-interactive() { [[ $- == *i* ]]; } @@ -23,8 +25,8 @@ cache() { [[ -d "$CACHE_DIR" ]] || mkdir -p "$CACHE_DIR" is-callable "$1" || return 1 - local cache="${CACHE_DIR}/$1-$(basename $SHELL)" - if [[ ! -f "$cache" && -s "$cache" ]]; then + local cache="${CACHE_DIR}/$1-${SHELL##*/}" + if [[ ! -f "$cache" || ! -s "$cache" ]]; then echo "Caching $1" $@ > "$cache" 2> /dev/null fi