diff --git a/run b/run index 0cf8903..72bb49b 100755 --- a/run +++ b/run @@ -316,8 +316,6 @@ __GET_LOGFILE() { || [[ $SCWRYPT_NAME =~ interactive ]] \ && return 0 - echo 'gets a logfile' >&2 - echo "$SCWRYPTS_LOG_PATH/$(echo $GROUP/$TYPE/$NAME | sed 's/^\.\///; s/\//\%/g').log" } diff --git a/zsh/lib/scwrypts/run.module.zsh b/zsh/lib/scwrypts/run.module.zsh index 8ee10c9..648171d 100644 --- a/zsh/lib/scwrypts/run.module.zsh +++ b/zsh/lib/scwrypts/run.module.zsh @@ -20,14 +20,14 @@ SCWRYPTS__GET_AVAILABLE_SCWRYPTS() { GROUP_TYPE=$(eval echo '$SCWRYPTS_TYPE__'$GROUP) [ $GROUP_TYPE ] && MINDEPTH=1 && GROUP_TYPE="$GROUP_TYPE\\/" || MINDEPTH=2 - { - cd "$GROUP_PATH" - find . -mindepth $MINDEPTH -type f -executable \ - | grep -v '\.git' \ - | grep -v 'node_modules' \ - | sed "s/^\\.\\///; s/\\.[^.]*$//; s/^/$GROUP_TYPE/" \ - | sed "s|\\([^/]*\\)/\(.*\)$|$(printf $__COLOR_RESET)\\2^$(printf $TYPE_COLOR)\\1^$(printf $GROUP_COLOR)$GROUP$(printf $__COLOR_RESET)|" \ + command -v SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__$GROUP >/dev/null 2>&1 \ + && LOOKUP=SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__$GROUP \ + || LOOKUP=SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__scwrypts \ ; + + { + $LOOKUP \ + | sed "s|\\([^/]*\\)/\(.*\)$|$(printf $__COLOR_RESET)\\2^$(printf $TYPE_COLOR)\\1^$(printf $GROUP_COLOR)$GROUP$(printf $__COLOR_RESET)|" \ } & LOOKUP_PIDS+=($!) done @@ -46,6 +46,17 @@ SCWRYPTS__SEPARATE_SCWRYPT_SELECTION() { done } +SCWRYPTS__LIST_AVAILABLE_SCWRYPTS__scwrypts() { + # implementation should output lines of the following format: + # "${SCWRYPT_TYPE}/${SCWRYPT_NAME}" + cd "$GROUP_PATH" + find . -mindepth $MINDEPTH -type f -executable \ + | grep -v '\.git' \ + | grep -v 'node_modules' \ + | sed "s/^\\.\\///; s/\\.[^.]*$//; s/^/$GROUP_TYPE/" \ + ; +} + SCWRYPTS__GET_RUNSTRING() { local GROUP_PATH=$(eval echo '$SCWRYPTS_ROOT__'$SCWRYPT_GROUP) local RUNSTRING @@ -60,7 +71,7 @@ SCWRYPTS__GET_RUNSTRING() { return 1 } - typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE} >/dev/null 2>&1 && { + [ ! $RUNSTRING ] && typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE} >/dev/null 2>&1 && { RUNSTRING=$(SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE}) [ ! $RUNSTRING ] && { ERROR "SCWRYPTS__GET_RUNSTRING__${SCWRYPT_GROUP}__${SCWRYPT_TYPE} error" @@ -68,7 +79,7 @@ SCWRYPTS__GET_RUNSTRING() { } } - typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE} >/dev/null 2>&1 && { + [ ! $RUNSTRING ] && typeset -f SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE} >/dev/null 2>&1 && { RUNSTRING=$(SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE}) [ ! $RUNSTRING ] && { ERROR "SCWRYPTS__GET_RUNSTRING__${SCWRYPT_TYPE} error" diff --git a/zsh/scwrypts/environment/edit b/zsh/scwrypts/environment/edit index 858e7ef..1e3d660 100755 --- a/zsh/scwrypts/environment/edit +++ b/zsh/scwrypts/environment/edit @@ -21,6 +21,7 @@ for ENV_FILE in ${ENV_FILES[@]} do [ ! -f "$ENV_FILE" ] && { STATUS "Creating '$ENV_FILE'..." \ + && mkdir -p "$(dirname "$ENV_FILE")" \ && touch "$ENV_FILE" \ && ((CREATED+=1)) \ && SUCCESS "created '$ENV_NAME'" \ diff --git a/zsh/system/config/symlinks b/zsh/system/config/symlinks index e036421..be243d3 100755 --- a/zsh/system/config/symlinks +++ b/zsh/system/config/symlinks @@ -18,10 +18,18 @@ SETUP_SYMLINK() { [ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG' local SOURCE_CONFIG="$1" - [ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && FAIL 2 "no such file or directory '$SOURCE_CONFIG'" - local TARGET_CONFIG="$HOME/.config/$2" + [ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && [ -f "$TARGET_CONFIG" ] && { + INFO 'SOURCE_CONFIG is not tracked; copying from TARGET_CONFIG' + mkdir -p "$(dirname "$SOURCE_CONFIG")" + cp "$TARGET_CONFIG" "$SOURCE_CONFIG" + } + [ ! -f "$SOURCE_CONFIG" ] && [ ! -d "$SOURCE_CONFIG" ] && { + WARNING "no such file or directory '$SOURCE_CONFIG'" + return 0 + } + [ ! -d $(dirname "$TARGET_CONFIG") ] && mkdir -p $(dirname "$TARGET_CONFIG") [[ $SAFE_SYMLINKS -eq 1 ]] \