Add $ENABLED_DIR and move $DOTFILES

This commit is contained in:
Henrik Lissner 2016-12-16 18:33:59 -05:00
parent efa692a819
commit b8aeeccc86
2 changed files with 9 additions and 8 deletions

View file

@ -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"

View file

@ -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