v4.0.0
===================================================================== Big day! V4 is finally live. This INCLUDES some BREAKING CHANGES to ZSH TYPE scwrypts! Please refer to the readme for upgrade details (more specifically docs/upgrade/v3-to-v4.md) Upgrade is SUPER EASY, so please take the time to do so. --- New Features ---------------------------------------------------- - zsh type scwrypts have an upgraded runstring to improve context setup and simplicity to the scwrypt-writer - scwrypts now publishes the package (scwrypts) to PyPi; this provides a simple way to invoke scwrypts from python-based environments as well as the entire scwrypts python library suite pip install scwrypts - scwrypts now publishes the package (scwrypts) to npm; this provides a simple way to invoke scwrypts from nodesjs environments npm install scwrypts --- Bug Fixes ------------------------------------------------------- - scwrypts runner prompts which use the zshbuiltin "read" now appropriately read input from tty, pipe, files, and user input - virtualenv refresh now loads and prepares the scwrypts virtual environments correctly --- Changes --------------------------------------------------------- - created the (-v, --log-level) scwrypts arguments as improvements of and replacements to the --verbose and --no-log flags - (-n) is now an alias for (--log-level 0) - (--no-log) is the same as (-n) for compatibility, but will be removed in 4.2 - zsh/lib/utils/io print functions now *interact with log-level* various log levels will now only display the appropriate console prints for the specified log level - zsh/lib/utils/io:INFO has been renamed to DEBUG to align with log-level output; please use DEBUG for debug messages and REMINDER for important user messages - created zsh/lib/utils/io:FZF_USER_INPUT as a *drop-in replacement* for the confusing FZF_HEAD and FZF_TAIL commands. Update by literally changing any instances of FZF_HEAD or FZF_TAIL with FZF_USER_INPUT - FZF_HEAD and FZF_TAIL will be removed in 4.2 - zsh/lib/utils/io:READ (and other zshbuiltin/read-based prompts) now accept a --force-user-input flag in case important checks should require an admin's approval. This flag will ensure that piped input and the `scwrypts -y` flag are ignored for the single prompt. - zsh/lib/utils/color has been updated to use color names which match the ANSI color names - zsh/hello-world has been reduced to a minimal example; this is to emphasize ease-of-use with v4 - zsh/sanity-check is a scwrypts/run testing helper and detailed starting reference (helpful since hello-world is now minimal) - various refactor, updates, and improvements to the scwrypts runner - migrated all zsh scwrypts and plugins to use v4 runner syntax - zsh - plugins/kubectl - plugins/ci - refactored py/lib into py/lib/scwrypts (PyPi)
This commit is contained in:
@ -1,10 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/aws/ecr
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
ECR_LOGIN $@
|
||||
MAIN() {
|
||||
ECR_LOGIN $@
|
||||
}
|
||||
|
@ -3,11 +3,9 @@ DEPENDENCIES+=(jq)
|
||||
REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT)
|
||||
|
||||
use cloud/aws/cli
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
EFS_CONNECT() {
|
||||
MAIN() {
|
||||
GETSUDO || exit 1
|
||||
[ ! -d $AWS__EFS__LOCAL_MOUNT_POINT ] && {
|
||||
sudo mkdir $AWS__EFS__LOCAL_MOUNT_POINT \
|
||||
@ -64,6 +62,3 @@ EFS_CONNECT() {
|
||||
FAIL 2 "unable to mount '$FS_ID'"
|
||||
}
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
EFS_CONNECT $@
|
||||
|
@ -3,11 +3,9 @@ DEPENDENCIES+=(jq)
|
||||
REQUIRED_ENV+=(AWS__EFS__LOCAL_MOUNT_POINT)
|
||||
|
||||
use cloud/aws/cli
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
EFS_DISCONNECT() {
|
||||
MAIN() {
|
||||
[ ! -d "$AWS__EFS__LOCAL_MOUNT_POINT" ] && {
|
||||
STATUS 'no efs currently mounted'
|
||||
exit 0
|
||||
@ -32,6 +30,3 @@ EFS_DISCONNECT() {
|
||||
&& SUCCESS "done" \
|
||||
|| FAIL 2 "failed to unmount '$EFS'"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
EFS_DISCONNECT $@
|
||||
|
@ -1,10 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/aws/eks
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
EKS__CLUSTER_LOGIN $@
|
||||
MAIN() {
|
||||
EKS__CLUSTER_LOGIN $@
|
||||
}
|
||||
|
@ -1,19 +1,11 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/aws/rds
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
CREATE_BACKUP() {
|
||||
MAIN() {
|
||||
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
|
||||
RDS__GET_DATABASE_CREDENTIALS $@ || return 1
|
||||
|
||||
PG_DUMP
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
CREATE_BACKUP $@
|
||||
|
@ -1,20 +1,11 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/aws/rds
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
RDS_INTERACTIVE_LOGIN() {
|
||||
MAIN() {
|
||||
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
|
||||
RDS__GET_DATABASE_CREDENTIALS $@ || return 1
|
||||
|
||||
POSTGRES__LOGIN_INTERACTIVE
|
||||
}
|
||||
|
||||
|
||||
#####################################################################
|
||||
RDS_INTERACTIVE_LOGIN $@
|
||||
|
@ -1,20 +1,11 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/aws/rds
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
LOAD_BACKUP() {
|
||||
MAIN() {
|
||||
local DB_HOST DB_PORT DB_NAME DB_USER DB_PASS
|
||||
RDS__GET_DATABASE_CREDENTIALS $@ || return 1
|
||||
|
||||
PG_RESTORE
|
||||
}
|
||||
|
||||
|
||||
#####################################################################
|
||||
LOAD_BACKUP $@
|
||||
|
@ -1,11 +1,9 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=(cli53)
|
||||
REQUIRED_ENV+=(AWS_PROFILE)
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
ROUTE53_BACKUP() {
|
||||
MAIN() {
|
||||
local BACKUP_PATH="$SCWRYPTS_OUTPUT_PATH/$ENV_NAME/aws-dns-backup/$(date '+%Y-%m-%d')"
|
||||
mkdir -p $BACKUP_PATH >/dev/null 2>&1
|
||||
|
||||
@ -25,12 +23,11 @@ ROUTE53_BACKUP() {
|
||||
for P in ${JOBS[@]}; do wait $P >/dev/null 2>&1; done
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
ROUTE53_GET_DOMAINS() {
|
||||
cli53 list --profile $AWS_PROFILE \
|
||||
| awk '{print $2;}' \
|
||||
| sed '1d; s/\.$//'\
|
||||
;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
ROUTE53_BACKUP
|
||||
|
@ -1,10 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/media-sync
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
MEDIA_SYNC__PULL $@
|
||||
MAIN() {
|
||||
MEDIA_SYNC__PULL $@
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use cloud/media-sync
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
MEDIA_SYNC__PUSH $@
|
||||
MAIN() {
|
||||
MEDIA_SYNC__PUSH $@
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
POSTGRES__LOGIN_INTERACTIVE $@
|
||||
|
||||
MAIN() {
|
||||
POSTGRES__LOGIN_INTERACTIVE $@
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
PG_DUMP $@
|
||||
|
||||
MAIN() {
|
||||
PG_DUMP $@
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
PG_RESTORE $@
|
||||
|
||||
MAIN() {
|
||||
PG_RESTORE $@
|
||||
}
|
||||
|
@ -1,13 +1,9 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use db/postgres
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
RUN_SQL_POSTGRES() {
|
||||
MAIN() {
|
||||
WARNING " \nthis function is in a beta state\n "
|
||||
local _PASS _ARGS=()
|
||||
POSTGRES__SET_LOGIN_ARGS $@
|
||||
|
||||
@ -43,9 +39,3 @@ RUN_SQL_POSTGRES() {
|
||||
&& SUCCESS "finished running '$INPUT_FILE'" \
|
||||
|| FAIL 3 "something went wrong running '$INPUT_FILE' (see above)"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
WARNING
|
||||
WARNING 'this function is in a beta state'
|
||||
WARNING
|
||||
RUN_SQL_POSTGRES $@
|
||||
|
@ -1,11 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=(docker)
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
DOCKER_CLEAN() {
|
||||
MAIN() {
|
||||
WARNING 'this will prune all docker resources from the current machine'
|
||||
WARNING 'pruned resources are PERMANENTLY DELETED'
|
||||
yN 'continue?' || return 1
|
||||
@ -14,6 +11,3 @@ DOCKER_CLEAN() {
|
||||
SUCCESS "IMAGE : $(docker image prune -f 2>/dev/null | tail -n 1)"
|
||||
SUCCESS "VOLUME : $(docker volume prune -f 2>/dev/null | tail -n 1)"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
DOCKER_CLEAN $@
|
||||
|
@ -1,8 +1,6 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
SUCCESS 'hello world!'
|
||||
MAIN() {
|
||||
SUCCESS 'Hello, World!'
|
||||
}
|
||||
|
@ -1,17 +1,9 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use helm
|
||||
use scwrypts
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
unset USAGE
|
||||
HELM__TEMPLATE__GET $@
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
MAIN $@
|
||||
|
@ -1,17 +1,9 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use helm
|
||||
use scwrypts
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
unset USAGE
|
||||
HELM__DEPENDENCY__UPDATE $@
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
MAIN $@
|
||||
|
@ -86,7 +86,7 @@ RDS__GET_DATABASE_CREDENTIALS() {
|
||||
user-input ) _RDS_AUTH__userinput ;;
|
||||
esac
|
||||
|
||||
[[ $PRINT_PASSWORD -eq 1 ]] && INFO "password : $DB_PASS"
|
||||
[[ $PRINT_PASSWORD -eq 1 ]] && DEBUG "password : $DB_PASS"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ TALLY() {
|
||||
true ) printf "$NEW_VALUE" ;;
|
||||
false )
|
||||
case $TALLY_NAME in
|
||||
default ) INFO "current tally : $NEW_VALUE" ;;
|
||||
* ) INFO "$TALLY_NAME : $NEW_VALUE" ;;
|
||||
default ) SUCCESS "current tally : $NEW_VALUE" ;;
|
||||
* ) SUCCESS "$TALLY_NAME : $NEW_VALUE" ;;
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ SCWRYPTS__SELECT_ENV() {
|
||||
}
|
||||
|
||||
SCWRYPTS__SELECT_OR_CREATE_ENV() {
|
||||
SCWRYPTS__GET_ENV_NAMES | FZF_TAIL 'select / create an environment'
|
||||
SCWRYPTS__GET_ENV_NAMES | FZF_USER_INPUT 'select / create an environment'
|
||||
}
|
||||
|
||||
SCWRYPTS__GET_ENV_FILES() {
|
||||
|
@ -8,15 +8,13 @@ use scwrypts/run
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__RUN() {
|
||||
SCWRYPTS__RUN() { # context wrapper to run scwrypts within scwrypts
|
||||
local EXIT_CODE=0
|
||||
((SUBSCWRYPT+=1))
|
||||
|
||||
echo "--- START SUBSCWRYPT=$SUBSCWRYPT $@"
|
||||
SUBSCWRYPT=$SUBSCWRYPT $SCWRYPTS_ROOT/run $@
|
||||
EXIT_CODE=$?
|
||||
|
||||
((SUBSCWRYPT-=1))
|
||||
return $EXIT_CODE
|
||||
echo "--- END SUBSCWRYPT=$SUBSCWRYPT $@"
|
||||
}
|
||||
|
@ -112,6 +112,58 @@ SCWRYPTS__GET_RUNSTRING() {
|
||||
SCWRYPTS__GET_RUNSTRING__zsh() {
|
||||
__CHECK_DEPENDENCY zsh || return 1
|
||||
|
||||
local SCWRYPT_FILENAME
|
||||
|
||||
[ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \
|
||||
&& SCWRYPT_FILENAME="$GROUP_PATH/$SCWRYPT_NAME" \
|
||||
|| SCWRYPT_FILENAME="$GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \
|
||||
;
|
||||
|
||||
printf "
|
||||
source '$SCWRYPT_FILENAME'
|
||||
CHECK_ENVIRONMENT
|
||||
ERRORS=0
|
||||
|
||||
export USAGE=\"
|
||||
usage: -
|
||||
|
||||
args: -
|
||||
|
||||
options: -
|
||||
-h, --help display this message and exit
|
||||
|
||||
description: -
|
||||
\"
|
||||
|
||||
[ ! \$USAGE__usage ] && export USAGE__usage='[...options...]'
|
||||
|
||||
() {
|
||||
local MAIN_ARGS=()
|
||||
local VARSPLIT
|
||||
while [[ \$# -gt 0 ]]
|
||||
do
|
||||
case \$1 in
|
||||
-[a-z][a-z]* )
|
||||
VARSPLIT=\$(echo \"\$1 \" | sed 's/^\\\\(-.\\\\)\\\\(.*\\\\) /\\\\1 -\\\\2/')
|
||||
set -- throw-away \$(echo \" \$VARSPLIT \") \${@:2}
|
||||
;;
|
||||
-h | --help ) USAGE; exit 0 ;;
|
||||
* ) MAIN_ARGS+=(\$1) ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
MAIN \${MAIN_ARGS[@]}
|
||||
} "
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
SCWRYPTS__GET_RUNSTRING__zsh_v3() {
|
||||
WARNING "scwrypts zsh/v3 runstrings are now deprecated; please update to scwrypts v4 format"
|
||||
|
||||
__CHECK_DEPENDENCY zsh || return 1
|
||||
|
||||
[ $(eval echo '$SCWRYPTS_TYPE__'$SCWRYPT_GROUP) ] \
|
||||
&& echo "source $GROUP_PATH/$SCWRYPT_NAME" \
|
||||
|| echo "source $GROUP_PATH/$SCWRYPT_TYPE/$SCWRYPT_NAME" \
|
||||
|
@ -85,8 +85,6 @@ CREATE_VIRTUALENV__scwrypts__py() {
|
||||
|
||||
DEPENDENCIES=(virtualenv) CHECK_ENVIRONMENT || return 1
|
||||
|
||||
local VIRTUALENV_PATH="$1"
|
||||
|
||||
STATUS 'creating python virtualenv'
|
||||
local PY PYTHON
|
||||
for PY in $(echo $SCWRYPTS_PREFERRED_PYTHON_VERSIONS__scwrypts)
|
||||
@ -141,8 +139,6 @@ CREATE_VIRTUALENV__scwrypts__zx() {
|
||||
|
||||
DEPENDENCIES=(nodeenv) CHECK_ENVIRONMENT || return 1
|
||||
|
||||
local VIRTUALENV_PATH="$1"
|
||||
|
||||
STATUS 'setting up nodeenv'
|
||||
nodeenv $VIRTUALENV_PATH --node=$SCWRYPTS_NODE_VERSION__scwrypts \
|
||||
&& SUCCESS 'node virtualenv created' \
|
||||
|
@ -2,22 +2,22 @@ __BLACK='\033[0;30m'
|
||||
__DARK_GRAY='\033[1;30m'
|
||||
|
||||
__RED='\033[0;31m'
|
||||
__LIGHT_RED='\033[1;31m'
|
||||
__BRIGHT_RED='\033[1;31m'
|
||||
|
||||
__GREEN='\033[0;32m'
|
||||
__LIGHT_GREEN='\033[1;32m'
|
||||
__BRIGHT_GREEN='\033[1;32m'
|
||||
|
||||
__ORANGE='\033[0;33m'
|
||||
__YELLOW='\033[1;33m'
|
||||
__YELLOW='\033[0;33m'
|
||||
__BRIGHT_YELLOW='\033[1;33m'
|
||||
|
||||
__BLUE='\033[1;34m'
|
||||
__DARK_BLUE='\033[0;34m'
|
||||
__BLUE='\033[0;34m'
|
||||
__BRIGHT_BLUE='\033[1;34m'
|
||||
|
||||
__PURPLE='\033[1;35m'
|
||||
__DARK_PURPLE='\033[0;35m'
|
||||
__MAGENTA='\033[0;35m'
|
||||
__BRIGHT_MAGENTA='\033[1;35m'
|
||||
|
||||
__CYAN='\033[1;36m'
|
||||
__DARK_CYAN='\033[0;36m'
|
||||
__CYAN='\033[0;36m'
|
||||
__BRIGHT_CYAN='\033[1;36m'
|
||||
|
||||
__WHITE='\033[1;37m'
|
||||
__LIGHT_GRAY='\033[0;37m'
|
||||
@ -27,17 +27,17 @@ __COLOR_RESET='\033[0m'
|
||||
__GET_RANDOM_COLOR() {
|
||||
local COLORS=(
|
||||
$__RED
|
||||
$__LIGHT_RED
|
||||
$__BRIGHT_RED
|
||||
$__GREEN
|
||||
$__LIGHT_GREEN
|
||||
$__ORANGE
|
||||
$__BRIGHT_GREEN
|
||||
$__YELLOW
|
||||
$__BRIGHT_YELLOW
|
||||
$__BLUE
|
||||
$__DARK_BLUE
|
||||
$__PURPLE
|
||||
$__DARK_PURPLE
|
||||
$__BRIGHT_BLUE
|
||||
$__MAGENTA
|
||||
$__BRIGHT_MAGENTA
|
||||
$__CYAN
|
||||
$__DARK_CYAN
|
||||
$__BRIGHT_CYAN
|
||||
$__WHITE
|
||||
)
|
||||
print "$__COLOR_RESET${COLORS[$(shuf -i 1-${#COLORS[@]} -n 1)]}"
|
||||
|
@ -1,13 +1,14 @@
|
||||
__CHECK_DEPENDENCIES() {
|
||||
local DEP ERROR=0
|
||||
local DEP ERRORS=0
|
||||
local SCWRYPTS_LOG_LEVEL=1
|
||||
[ ! $E ] && E=ERROR
|
||||
|
||||
DEPENDENCIES=($(echo $DEPENDENCIES | sed 's/ \+/\n/g' | sort -u))
|
||||
|
||||
for DEP in ${DEPENDENCIES[@]}; do __CHECK_DEPENDENCY $DEP || ((ERROR+=1)); done
|
||||
__CHECK_COREUTILS || ((ERROR+=$?))
|
||||
for DEP in ${DEPENDENCIES[@]}; do __CHECK_DEPENDENCY $DEP || ((ERRORS+=1)); done
|
||||
__CHECK_COREUTILS || ((ERRORS+=$?))
|
||||
|
||||
return $ERROR
|
||||
return $ERRORS
|
||||
}
|
||||
|
||||
__CHECK_DEPENDENCY() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
__CHECK_REQUIRED_ENV() {
|
||||
local SCWRYPTS_LOG_LEVEL=1
|
||||
local VAR ERROR=0
|
||||
REQUIRED_ENV=($(echo $REQUIRED_ENV | sed 's/\s\+/\n/g' | sort -u))
|
||||
for VAR in ${REQUIRED_ENV[@]}; do __CHECK_ENV_VAR $VAR || ((ERROR+=1)); done
|
||||
|
57
zsh/lib/utils/io.fzf.zsh
Normal file
57
zsh/lib/utils/io.fzf.zsh
Normal file
@ -0,0 +1,57 @@
|
||||
FZF() {
|
||||
[ $CI ] && FAIL 1 'currently in CI, but FZF requires user input'
|
||||
|
||||
local FZF_ARGS=()
|
||||
|
||||
FZF_ARGS+=(-i)
|
||||
FZF_ARGS+=(--ansi)
|
||||
FZF_ARGS+=(--bind=ctrl-c:cancel)
|
||||
FZF_ARGS+=(--height=50%)
|
||||
FZF_ARGS+=(--layout=reverse)
|
||||
|
||||
local SELECTION=$(fzf ${FZF_ARGS[@]} --prompt "$1 : " ${@:2} 2>/dev/tty)
|
||||
PROMPT "$1"
|
||||
|
||||
[ $BE_QUIET ] || {
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] && echo $SELECTION >&2
|
||||
}
|
||||
echo $SELECTION
|
||||
[ $SELECTION ]
|
||||
}
|
||||
|
||||
FZF_USER_INPUT() { # allow user to type custom answers; reconfirm if ambiguous with select
|
||||
local FZF_OUTPUT=$(BE_QUIET=1 FZF $@ --print-query | sed '/^$/d' | sort -u)
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] && echo $FZF_OUTPUT | head -n1 >&2
|
||||
[ ! $FZF_OUTPUT ] && return 1
|
||||
|
||||
[[ $(echo "$FZF_OUTPUT" | wc -l) -eq 1 ]] \
|
||||
&& { echo "$FZF_OUTPUT"; return 0; }
|
||||
|
||||
local FZF_OUTPUT=$(
|
||||
echo "$FZF_OUTPUT" \
|
||||
| sed "1s/\$/^$(printf "$__LIGHT_GRAY\\033[3m")<- what you typed$(printf $__COLOR_RESET)/" \
|
||||
| sed "2s/\$/^$(printf "$__LIGHT_GRAY\\033[3m")<- what you selected$(printf $__COLOR_RESET)/" \
|
||||
| column -ts '^' \
|
||||
| BE_QUIET=1 FZF "$@ (clarify)" \
|
||||
)
|
||||
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] && echo $FZF_OUTPUT >&2
|
||||
FZF_OUTPUT=$(echo $FZF_OUTPUT | sed 's/\s\+<- what you .*$//')
|
||||
echo $FZF_OUTPUT
|
||||
[ $FZF_OUTPUT ]
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
### vvv DEPRECATED vvv ##############################################
|
||||
#####################################################################
|
||||
|
||||
FZF_HEAD() { # prefer user input over selected
|
||||
WARNING 'FZF_HEAD is deprecated and will be unavailable in v4.2; please switch to FZF_USER_INPUT (drop-in fix!)'
|
||||
FZF $@ --print-query | sed '/^$/d' | head -n1;
|
||||
}
|
||||
FZF_TAIL() { # prefer selected over user input
|
||||
WARNING 'FZF_TAIL is deprecated and will be unavailable in v4.2; please switch to FZF_USER_INPUT (drop-in fix!)'
|
||||
FZF $@ --print-query | sed '/^$/d' | tail -n1;
|
||||
}
|
||||
|
||||
#####################################################################
|
38
zsh/lib/utils/io.print.zsh
Normal file
38
zsh/lib/utils/io.print.zsh
Normal file
@ -0,0 +1,38 @@
|
||||
PRINT() {
|
||||
local MESSAGE
|
||||
local LAST_LINE_END='\n'
|
||||
local STDERR=1
|
||||
local STDOUT=0
|
||||
|
||||
local LTRIM=1
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-n | --no-trim-tabs ) LTRIM=0 ;;
|
||||
-x | --no-line-end ) LAST_LINE_END='' ;;
|
||||
-o | --use-stdout ) STDOUT=1; STDERR=0 ;;
|
||||
* ) MESSAGE+="$(echo $1) " ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
MESSAGE="$(echo "$MESSAGE" | sed 's/%/%%/g')"
|
||||
|
||||
local STYLED_MESSAGE="$({
|
||||
printf "${COLOR}"
|
||||
while IFS='' read line
|
||||
do
|
||||
[[ $PREFIX =~ ^[[:space:]]\+$ ]] && printf '\n'
|
||||
|
||||
printf "${PREFIX} : $(echo "$line" | sed 's/^ \+//; s/ \+$//')"
|
||||
|
||||
PREFIX=$(echo $PREFIX | sed 's/./ /g')
|
||||
done <<< $MESSAGE
|
||||
})"
|
||||
STYLED_MESSAGE="${COLOR}$(echo "$STYLED_MESSAGE" | sed 's/%/%%/g')${__COLOR_RESET}${LAST_LINE_END}"
|
||||
|
||||
[[ $STDERR -eq 1 ]] && printf $STYLED_MESSAGE >&2
|
||||
[[ $STDOUT -eq 1 ]] && printf $STYLED_MESSAGE
|
||||
|
||||
return 0
|
||||
}
|
65
zsh/lib/utils/io.usage.zsh
Normal file
65
zsh/lib/utils/io.usage.zsh
Normal file
@ -0,0 +1,65 @@
|
||||
USAGE() { # formatter for USAGE variable
|
||||
[ ! $USAGE ] && return 0
|
||||
local USAGE_LINE=$(echo $USAGE | grep -i '^[ ]*usage *:' | sed 's/^[ ]*//')
|
||||
|
||||
[ $USAGE__usage ] && echo $USAGE_LINE | grep -q 'usage: -' \
|
||||
&& USAGE_LINE=$(echo $USAGE_LINE | sed "s/usage: -/usage: $USAGE__usage/")
|
||||
|
||||
[ $__SCWRYPT ] \
|
||||
&& USAGE_LINE=$(
|
||||
echo $USAGE_LINE \
|
||||
| sed "s;^[^:]*:;& scwrypts $SCWRYPT_NAME --;" \
|
||||
| sed 's/ \{2,\}/ /g; s/scwrypts -- scwrypts/scwrypts/' \
|
||||
)
|
||||
|
||||
local THE_REST=$(echo $USAGE | grep -vi '^[ ]*usage *:' )
|
||||
|
||||
local DYNAMIC_USAGE_ELEMENT
|
||||
#
|
||||
# create dynamic usage elements (like 'args') by defining USAGE__<element>
|
||||
# then using the syntax "<element>: -" in your USAGE variable
|
||||
#
|
||||
# e.g.
|
||||
#
|
||||
# USAGE__args="
|
||||
# subcommand arg 1 arg 1 description
|
||||
# subcommand arg 2 some other description
|
||||
# "
|
||||
#
|
||||
# USAGE="
|
||||
# usage: some-command [...args...]
|
||||
#
|
||||
# args: -
|
||||
# -h, --help some arguments are applicable everywhere
|
||||
# "
|
||||
#
|
||||
for DYNAMIC_USAGE_ELEMENT in $(echo $THE_REST | sed -n 's/^\([^:]*\): -$/\1/p')
|
||||
do
|
||||
DYNAMIC_USAGE_ELEMENT_TEXT=$(eval echo '$USAGE__'$DYNAMIC_USAGE_ELEMENT)
|
||||
#[ $DYNAMIC_USAGE_ELEMENT_TEXT ] || continue
|
||||
|
||||
|
||||
case $DYNAMIC_USAGE_ELEMENT in
|
||||
description )
|
||||
DYNAMIC_USAGE_ELEMENT_TEXT=$(echo "$DYNAMIC_USAGE_ELEMENT_TEXT" | perl -p0e 's/^[\n\s]+//')
|
||||
DYNAMIC_USAGE_ELEMENT_TEXT="$__YELLOW\\033[03m$DYNAMIC_USAGE_ELEMENT_TEXT\\033[0m"
|
||||
;;
|
||||
* )
|
||||
DYNAMIC_USAGE_ELEMENT_TEXT=$(echo $DYNAMIC_USAGE_ELEMENT_TEXT | sed 's/[^ ]/ &/')
|
||||
;;
|
||||
esac
|
||||
|
||||
THE_REST=$(echo $THE_REST | perl -pe "s$DYNAMIC_USAGE_ELEMENT: -$DYNAMIC_USAGE_ELEMENT:\n$DYNAMIC_USAGE_ELEMENT_TEXT\n\n")
|
||||
done
|
||||
|
||||
# allow for dynamic 'description: -' but delete the 'description:' header line
|
||||
THE_REST=$(echo $THE_REST | sed '/^[ ]*description:$/d')
|
||||
|
||||
echo "$__BLUE$USAGE_LINE$__COLOR_RESET\n\n$THE_REST" \
|
||||
| sed "s/^\t\+//; s/\s\+$//; s/^\\s*$//;" \
|
||||
| sed '/./,$!d; :a; /^\n*$/{$d;N;ba;};' \
|
||||
| perl -p0e 's/\n{2,}/\n\n/g' \
|
||||
| perl -p0e 's/:\n{2,}/:\n/g' \
|
||||
| perl -p0e 's/([a-z]+:)\n([a-z]+:)/\2/g' \
|
||||
>&2
|
||||
}
|
@ -1,218 +1,104 @@
|
||||
PRINT() {
|
||||
local MESSAGE
|
||||
local LAST_LINE_END='\n'
|
||||
local STDERR=1
|
||||
local STDOUT=0
|
||||
|
||||
local LTRIM=1
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-n | --no-trim-tabs ) LTRIM=0 ;;
|
||||
-x | --no-line-end ) LAST_LINE_END='' ;;
|
||||
-o | --use-stdout ) STDOUT=1; STDERR=0 ;;
|
||||
* ) MESSAGE+="$(echo $1) " ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
MESSAGE="$(echo "$MESSAGE" | sed 's/%/%%/g')"
|
||||
|
||||
local STYLED_MESSAGE="$({
|
||||
printf "${COLOR}"
|
||||
while IFS='' read line
|
||||
do
|
||||
[[ $PREFIX =~ ^[[:space:]]\+$ ]] && printf '\n'
|
||||
|
||||
printf "${PREFIX} : $(echo "$line" | sed 's/^ \+//; s/ \+$//')"
|
||||
|
||||
PREFIX=$(echo $PREFIX | sed 's/./ /g')
|
||||
done <<< $MESSAGE
|
||||
})"
|
||||
STYLED_MESSAGE="${COLOR}$(echo "$STYLED_MESSAGE" | sed 's/%/%%/g')${__COLOR_RESET}${LAST_LINE_END}"
|
||||
|
||||
[[ $STDERR -eq 1 ]] && printf $STYLED_MESSAGE >&2
|
||||
[[ $STDOUT -eq 1 ]] && printf $STYLED_MESSAGE
|
||||
|
||||
return 0
|
||||
}
|
||||
#####################################################################
|
||||
### basic colorized print messages ##################################
|
||||
#####################################################################
|
||||
|
||||
source "${0:a:h}/io.print.zsh"
|
||||
[ ! $ERRORS ] && ERRORS=0
|
||||
ERROR() { PREFIX="ERROR ✖" COLOR=$__RED PRINT "$@"; ((ERRORS+=1)); }
|
||||
SUCCESS() { PREFIX="SUCCESS ✔" COLOR=$__GREEN PRINT "$@"; }
|
||||
WARNING() { PREFIX="WARNING " COLOR=$__ORANGE PRINT "$@"; }
|
||||
STATUS() { PREFIX="STATUS " COLOR=$__BLUE PRINT "$@"; }
|
||||
REMINDER() { PREFIX="REMINDER " COLOR=$__PURPLE PRINT "$@"; }
|
||||
INFO() { PREFIX="INFO ℹ" COLOR=$__WHITE PRINT "$@"; }
|
||||
|
||||
PROMPT() {
|
||||
PREFIX="PROMPT " COLOR=$__CYAN PRINT "$@"
|
||||
PREFIX="USER ⌨" COLOR=$__CYAN PRINT '' --no-line-end
|
||||
}
|
||||
|
||||
FAIL() { ERROR "${@:2}"; exit $1; }
|
||||
ABORT() { FAIL 69 'user abort'; }
|
||||
|
||||
CHECK_ERRORS() {
|
||||
local FAIL_OUT=1
|
||||
local DISPLAY_USAGE=1
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--no-fail ) FAIL_OUT=0 ;;
|
||||
--no-usage ) DISPLAY_USAGE=0 ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ ! $ERRORS ] && ERRORS=0
|
||||
[[ $ERRORS -eq 0 ]] && return 0
|
||||
|
||||
[[ $DISPLAY_USAGE -eq 1 ]] && USAGE
|
||||
|
||||
[[ $FAIL_OUT -eq 1 ]] && exit $ERRORS
|
||||
|
||||
ERROR() { # command encountered an error
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \
|
||||
&& PREFIX="ERROR ✖" COLOR=$__RED PRINT "$@"
|
||||
((ERRORS+=1))
|
||||
return $ERRORS
|
||||
}
|
||||
|
||||
USAGE() { # formatter for USAGE variable
|
||||
[ ! $USAGE ] && return 0
|
||||
local USAGE_LINE=$(echo $USAGE | grep -i '^[ ]*usage *:' | sed 's/^[ ]*//')
|
||||
|
||||
[ $USAGE__usage ] && echo $USAGE_LINE | grep -q 'usage: -' \
|
||||
&& USAGE_LINE=$(echo $USAGE_LINE | sed "s/usage: -/usage: $USAGE__usage/")
|
||||
|
||||
[ $__SCWRYPT ] \
|
||||
&& USAGE_LINE=$(
|
||||
echo $USAGE_LINE \
|
||||
| sed "s;^[^:]*:;& scwrypts $SCWRYPT_NAME --;" \
|
||||
| sed 's/ \{2,\}/ /g; s/scwrypts -- scwrypts/scwrypts/' \
|
||||
)
|
||||
|
||||
local THE_REST=$(echo $USAGE | grep -vi '^[ ]*usage *:' )
|
||||
|
||||
local DYNAMIC_USAGE_ELEMENT
|
||||
#
|
||||
# create dynamic usage elements (like 'args') by defining USAGE__<element>
|
||||
# then using the syntax "<element>: -" in your USAGE variable
|
||||
#
|
||||
# e.g.
|
||||
#
|
||||
# USAGE__args="
|
||||
# subcommand arg 1 arg 1 description
|
||||
# subcommand arg 2 some other description
|
||||
# "
|
||||
#
|
||||
# USAGE="
|
||||
# usage: some-command [...args...]
|
||||
#
|
||||
# args: -
|
||||
# -h, --help some arguments are applicable everywhere
|
||||
# "
|
||||
#
|
||||
for DYNAMIC_USAGE_ELEMENT in $(echo $THE_REST | sed -n 's/^\([^:]*\): -$/\1/p')
|
||||
do
|
||||
DYNAMIC_USAGE_ELEMENT_TEXT=$(eval echo '$USAGE__'$DYNAMIC_USAGE_ELEMENT)
|
||||
|
||||
[[ ! $DYNAMIC_USAGE_ELEMENT =~ ^description$ ]] \
|
||||
&& DYNAMIC_USAGE_ELEMENT_TEXT=$(echo $DYNAMIC_USAGE_ELEMENT_TEXT | sed 's/[^ ]/ &/')
|
||||
|
||||
THE_REST=$(echo $THE_REST | perl -pe "s/$DYNAMIC_USAGE_ELEMENT: -/$DYNAMIC_USAGE_ELEMENT:\n$DYNAMIC_USAGE_ELEMENT_TEXT\n\n/")
|
||||
done
|
||||
|
||||
# allow for dynamic 'description: -' but delete the 'description:' header line
|
||||
THE_REST=$(echo $THE_REST | sed '/^[ ]*description:$/d')
|
||||
|
||||
echo "$__DARK_BLUE$USAGE_LINE$__COLOR_RESET\n\n$THE_REST" \
|
||||
| sed "s/^\t\+//; s/\s\+$//; s/^\\s*$//;" \
|
||||
| sed '/./,$!d; :a; /^\n*$/{$d;N;ba;};' \
|
||||
| perl -p0e 's/\n{2,}/\n\n/g' \
|
||||
| perl -p0e 's/:\n{2,}/:\n/g' \
|
||||
>&2
|
||||
SUCCESS() { # command completed successfully
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \
|
||||
&& PREFIX="SUCCESS ✔" COLOR=$__GREEN PRINT "$@"
|
||||
}
|
||||
|
||||
INPUT() {
|
||||
REMINDER() { # include sysadmin reminder or other important notice to users
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \
|
||||
&& PREFIX="REMINDER " COLOR=$__BRIGHT_MAGENTA PRINT "$@"
|
||||
}
|
||||
|
||||
STATUS() { # general status updates (prefer this to generic 'echo')
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 2 ]] \
|
||||
&& PREFIX="STATUS " COLOR=$__BLUE PRINT "$@"
|
||||
}
|
||||
|
||||
WARNING() { # warning-level messages; not errors
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 3 ]] \
|
||||
&& PREFIX="WARNING " COLOR=$__YELLOW PRINT "$@"
|
||||
}
|
||||
|
||||
DEBUG() { # helpful during development or (sparingly) to help others' development
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 4 ]] \
|
||||
&& PREFIX="DEBUG ℹ" COLOR=$__WHITE PRINT "$@"
|
||||
}
|
||||
|
||||
PROMPT() { # you probably want to use yN or INPUT from below
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] \
|
||||
&& PREFIX="PROMPT " COLOR=$__CYAN PRINT "$@" \
|
||||
&& PREFIX="USER ⌨" COLOR=$__BRIGHT_CYAN PRINT '' --no-line-end \
|
||||
;
|
||||
}
|
||||
|
||||
FAIL() { SCWRYPTS_LOG_LEVEL=1 ERROR "${@:2}"; exit $1; }
|
||||
ABORT() { FAIL 69 'user abort'; }
|
||||
|
||||
#####################################################################
|
||||
### check for reported errors and format USAGE contents #############
|
||||
#####################################################################
|
||||
|
||||
CHECK_ERRORS() {
|
||||
local FAIL_OUT=true
|
||||
local DISPLAY_USAGE=true
|
||||
|
||||
[ ! $ERRORS ] && ERRORS=0
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--fail ) FAIL_OUT=true ;;
|
||||
--no-fail ) FAIL_OUT=false ;;
|
||||
|
||||
--usage ) DISPLAY_USAGE=true ;;
|
||||
--no-usage ) DISPLAY_USAGE=false ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[[ $ERRORS -eq 0 ]] && return 0
|
||||
|
||||
[[ $DISPLAY_USAGE =~ true ]] && USAGE
|
||||
|
||||
[[ $FAIL_OUT =~ true ]] && exit $ERRORS || return $ERRORS
|
||||
}
|
||||
|
||||
source "${0:a:h}/io.usage.zsh"
|
||||
|
||||
#####################################################################
|
||||
### facilitate user prompt and input ################################
|
||||
#####################################################################
|
||||
|
||||
# yes/no prompts && = yes (exit code 0)
|
||||
# || = no (exit code 1)
|
||||
Yn() { [[ ! $(READ_YN $@ '[Yn]') =~ [nN] ]]; } # default 'yes'
|
||||
yN() { [[ $(READ_YN $@ '[yN]') =~ [yY] ]]; } # default 'no'
|
||||
|
||||
INPUT() { # read a single line of user input
|
||||
PROMPT "${@:2}"
|
||||
READ $1
|
||||
local VALUE=$(eval echo '$'$1)
|
||||
[ $VALUE ]
|
||||
}
|
||||
|
||||
Yn() {
|
||||
PROMPT "$@ [Yn]"
|
||||
[ $CI ] && { echo y; return 0; }
|
||||
[ $__SCWRYPTS_YES ] && [[ $__SCWRYPTS_YES -eq 1 ]] && { echo y; return 0; }
|
||||
source "${0:a:h}/io.fzf.zsh" # allow user to select from a list of inputs
|
||||
|
||||
local Yn; READ -k Yn; echo >&2
|
||||
[[ $Yn =~ [nN] ]] && return 1 || return 0
|
||||
}
|
||||
|
||||
yN() {
|
||||
PROMPT "$@ [yN]"
|
||||
[ $CI ] && { echo y; return 0; }
|
||||
[ $__SCWRYPTS_YES ] && [[ $__SCWRYPTS_YES -eq 1 ]] && { echo y; return 0; }
|
||||
|
||||
local yN; READ -k yN; echo >&2
|
||||
[[ $yN =~ [yY] ]] && return 0 || return 1
|
||||
}
|
||||
|
||||
CAPTURE() {
|
||||
[ ! $USAGE ] && USAGE="
|
||||
usage: stdout-varname stderr-varname [...cmd and args...]
|
||||
|
||||
captures stdout and stderr on separate variables for a command
|
||||
"
|
||||
{
|
||||
IFS=$'\n' read -r -d '' $2;
|
||||
IFS=$'\n' read -r -d '' $1;
|
||||
} < <((printf '\0%s\0' "$(${@:3})" 1>&2) 2>&1)
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
GETSUDO() {
|
||||
echo "\\033[1;36mPROMPT : checking sudo password...\\033[0m" >&2
|
||||
sudo echo hi >/dev/null 2>&1 </dev/tty \
|
||||
&& SUCCESS '...authenticated!' \
|
||||
|| { ERROR 'failed :c'; return 1; }
|
||||
}
|
||||
|
||||
LESS() { less -R $@ </dev/tty >/dev/tty; }
|
||||
|
||||
FZF() {
|
||||
EDIT() { # edit a file in user's preferred editor
|
||||
[ $CI ] && {
|
||||
ERROR 'currently in CI, but FZF requires user input'
|
||||
exit 1
|
||||
}
|
||||
|
||||
local FZF_ARGS=()
|
||||
|
||||
FZF_ARGS+=(-i)
|
||||
FZF_ARGS+=(--ansi)
|
||||
FZF_ARGS+=(--bind=ctrl-c:cancel)
|
||||
FZF_ARGS+=(--height=50%)
|
||||
FZF_ARGS+=(--layout=reverse)
|
||||
|
||||
local SELECTION=$(fzf ${FZF_ARGS[@]} --layout=reverse --prompt "$1 : " ${@:2})
|
||||
PROMPT "$1"
|
||||
echo $SELECTION >&2
|
||||
echo $SELECTION
|
||||
}
|
||||
FZF_HEAD() { FZF $@ --print-query | sed '/^$/d' | head -n1; } # prefer user input over selected
|
||||
FZF_TAIL() { FZF $@ --print-query | sed '/^$/d' | tail -n1; } # prefer selected over user input
|
||||
|
||||
READ() {
|
||||
[ $CI ] && {
|
||||
INFO 'currently in CI, skipping READ'
|
||||
return 0
|
||||
}
|
||||
read $@ </dev/tty
|
||||
}
|
||||
|
||||
EDIT() {
|
||||
[ $CI ] && {
|
||||
INFO 'currently in CI, skipping EDIT'
|
||||
WARNING 'currently in CI, skipping EDIT'
|
||||
return 0
|
||||
}
|
||||
|
||||
@ -221,6 +107,12 @@ EDIT() {
|
||||
SUCCESS "finished editing '$1'!"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
### basic commands with tricky states or default requirements #######
|
||||
#####################################################################
|
||||
|
||||
LESS() { less -R $@ </dev/tty >/dev/tty; }
|
||||
|
||||
YQ() {
|
||||
yq --version | grep -q mikefarah || {
|
||||
yq $@
|
||||
@ -229,3 +121,110 @@ YQ() {
|
||||
|
||||
yq eval '... comments=""' | yq $@
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
### other i/o utilities #############################################
|
||||
#####################################################################
|
||||
|
||||
CAPTURE() {
|
||||
[ ! $USAGE ] && USAGE="
|
||||
usage: stdout-varname stderr-varname [...cmd and args...]
|
||||
|
||||
captures stdout and stderr on separate variables for a command
|
||||
"
|
||||
{
|
||||
IFS=$'\n' read -r -d '' $2;
|
||||
IFS=$'\n' read -r -d '' $1;
|
||||
} < <((printf '\0%s\0' "$(${@:3})" 1>&2) 2>&1)
|
||||
}
|
||||
|
||||
|
||||
GETSUDO() {
|
||||
echo "\\033[1;36mPROMPT : checking sudo password...\\033[0m" >&2
|
||||
sudo echo hi >/dev/null 2>&1 </dev/tty \
|
||||
&& SUCCESS '...authenticated!' \
|
||||
|| { ERROR 'failed :c'; return 1; }
|
||||
}
|
||||
|
||||
READ() {
|
||||
[ $CI ] && [ -t 0 ] \
|
||||
&& FAIL 42 'currently in CI, but attempting interactive read; aborting'
|
||||
|
||||
local FORCE_USER_INPUT=false
|
||||
local ARGS=()
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--force-user-input ) FORCE_USER_INPUT=true ;;
|
||||
-k )
|
||||
ARGS+=($1)
|
||||
;;
|
||||
* ) ARGS+=($1) ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
while read -k -t 0; do :; done; # flush user stdin
|
||||
|
||||
case $FORCE_USER_INPUT in
|
||||
true )
|
||||
read ${PREARGS[@]} ${ARGS[@]} $@ </dev/tty
|
||||
;;
|
||||
false )
|
||||
[ -t 0 ] || ARGS=(-u 0 ${ARGS[@]})
|
||||
read ${ARGS[@]} $@
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
READ_YN() { # yes/no read is suprisingly tricky
|
||||
local FORCE_USER_INPUT=false
|
||||
local USERPROMPT=()
|
||||
local READ_ARGS=()
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--force-user-input )
|
||||
# overrides 'scwrypts -y' and stdin pipe but not CI
|
||||
FORCE_USER_INPUT=true
|
||||
READ_ARGS+=($1)
|
||||
;;
|
||||
* ) USERPROMPT+=($1) ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
##########################################
|
||||
|
||||
local SKIP_USER_INPUT=false
|
||||
|
||||
[ $CI ] \
|
||||
&& SKIP_USER_INPUT=true
|
||||
|
||||
[ $__SCWRYPTS_YES ] && [[ $__SCWRYPTS_YES -eq 1 ]] && [[ $FORCE_USER_INPUT =~ false ]] \
|
||||
&& SKIP_USER_INPUT=true
|
||||
|
||||
##########################################
|
||||
|
||||
local yn
|
||||
PROMPT "${USERPROMPT[@]}"
|
||||
|
||||
case $SKIP_USER_INPUT in
|
||||
true ) yn=y ;;
|
||||
false )
|
||||
[[ $FORCE_USER_INPUT =~ true ]] && [[ $SCWRYPTS_LOG_LEVEL -lt 1 ]] \
|
||||
&& echo -n "${USERPROMPT[@]} : " >&2
|
||||
|
||||
READ ${READ_ARGS[@]} -s -k yn
|
||||
|
||||
[[ $FORCE_USER_INPUT =~ true ]] && [[ $SCWRYPTS_LOG_LEVEL -lt 1 ]] \
|
||||
&& echo $yn >&2
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ $SCWRYPTS_LOG_LEVEL -ge 1 ]] && echo $yn >&2
|
||||
|
||||
echo $yn
|
||||
}
|
||||
|
@ -1,16 +1,11 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use media/youtube
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
DOWNLOAD_VIDEO() {
|
||||
MAIN() {
|
||||
local URLS=($@)
|
||||
|
||||
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL'))
|
||||
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_USER_INPUT 'enter URL'))
|
||||
[[ ${#URLS[@]} -eq 0 ]] && ABORT
|
||||
|
||||
local FILENAME=$(YT__GET_FILENAME $URLS)
|
||||
@ -23,6 +18,3 @@ DOWNLOAD_VIDEO() {
|
||||
&& SUCCESS "downloaded to '$YT__OUTPUT_DIR/$FILENAME'" \
|
||||
|| { ERROR "failed to download '$FILENAME'"; return 2; }
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
DOWNLOAD_VIDEO $@
|
||||
|
@ -1,16 +1,11 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use media/youtube
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
GET_AUDIO_CLIP() {
|
||||
MAIN() {
|
||||
local URLS=($@)
|
||||
|
||||
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_HEAD 'enter URL'))
|
||||
[[ ${#URLS[@]} -eq 0 ]] && URLS=($(echo '' | FZF_USER_INPUT 'enter URL'))
|
||||
[[ ${#URLS[@]} -eq 0 ]] && ABORT
|
||||
|
||||
local FILENAME=$(YT__GET_FILENAME $URLS)
|
||||
@ -26,9 +21,9 @@ GET_AUDIO_CLIP() {
|
||||
|
||||
LENGTH=$(GET_VIDEO_LENGTH "$INPUT_FILE")
|
||||
[ ! $LENGTH ] && { ERROR "unable to determine video length for '$INPUT_FILE'"; return 2; }
|
||||
START_TIME=$(echo 0 | FZF_HEAD "enter start time (0 ≤ t < $LENGTH)")
|
||||
START_TIME=$(echo 0 | FZF_USER_INPUT "enter start time (0 ≤ t < $LENGTH)")
|
||||
[ ! $START_TIME ] && ABORT
|
||||
END_TIME=$(echo $LENGTH | FZF_HEAD "enter end time ($START_TIME > t ≥ $LENGTH)")
|
||||
END_TIME=$(echo $LENGTH | FZF_USER_INPUT "enter end time ($START_TIME > t ≥ $LENGTH)")
|
||||
[ ! $END_TIME ] && ABORT
|
||||
|
||||
STATUS
|
||||
@ -37,7 +32,7 @@ GET_AUDIO_CLIP() {
|
||||
STATUS "end time : $END_TIME"
|
||||
STATUS
|
||||
OUTPUT_FILE=$(echo '' \
|
||||
| FZF_HEAD 'what should I call this clip? (.mp3)' \
|
||||
| FZF_USER_INPUT 'what should I call this clip? (.mp3)' \
|
||||
| sed 's/\.mp3$//' \
|
||||
)
|
||||
[ ! $OUTPUT_FILE ] && ABORT
|
||||
@ -49,6 +44,3 @@ GET_AUDIO_CLIP() {
|
||||
&& SUCCESS "created clip '$OUTPUT_FILE'" \
|
||||
|| { ERROR "error creating clip '$(basename $OUTPUT_FILE)' (see above)"; return 3; }
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
GET_AUDIO_CLIP $@
|
||||
|
@ -1,17 +1,8 @@
|
||||
#!/bin/zsh
|
||||
#####################################################################
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use misc/tally
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
unset USAGE
|
||||
TALLY $@
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
MAIN $@
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/latex
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
PDFLATEX() {
|
||||
MAIN() {
|
||||
[ ! $1 ] && FAIL 1 'must provide filename'
|
||||
local FILENAME=$(LATEX__GET_MAIN_FILENAME "$1")
|
||||
|
||||
@ -26,6 +21,3 @@ PDFLATEX() {
|
||||
|
||||
SUCCESS "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
PDFLATEX $@
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/latex
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
CLEAN_LATEX_LOGFILES() {
|
||||
MAIN() {
|
||||
local DIRECTORY=$(SCWRYPTS__GET_REALPATH ".")
|
||||
[ $1 ] && DIRECTORY="$(dirname "$(LATEX__GET_MAIN_FILENAME "$1")")"
|
||||
[ $DIRECTORY ] && [ -d $DIRECTORY ] \
|
||||
@ -18,6 +13,3 @@ CLEAN_LATEX_LOGFILES() {
|
||||
|
||||
SUCCESS "cleaned up latex artifacts in '$DIRECTORY'"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
CLEAN_LATEX_LOGFILES $@
|
||||
|
@ -1,15 +1,10 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/latex
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
TEMPLATE_DIR="${0:a:h}/templates"
|
||||
|
||||
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() {
|
||||
MAIN() {
|
||||
local DOCUMENT_DIR="$EXECUTION_DIR"
|
||||
local TEMPLATE=$(GET_TEMPLATES | FZF 'select a template')
|
||||
[ ! $TEMPLATE ] && ABORT
|
||||
@ -39,6 +34,8 @@ CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE() {
|
||||
SUCCESS "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
GET_TEMPLATES() {
|
||||
find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d"
|
||||
}
|
||||
@ -59,4 +56,4 @@ SLUGIFY_TITLE() {
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
CREATE_NEW_LATEX_DOCUMENT_FROM_TEMPLATE $@
|
||||
MAIN $@
|
||||
|
@ -1,10 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/latex
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
LATEX__GET_PDF $@
|
||||
MAIN() {
|
||||
LATEX__GET_PDF $@
|
||||
}
|
||||
|
@ -1,18 +1,10 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/latex
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
OPEN_PDF() {
|
||||
MAIN() {
|
||||
local PDF=$(LATEX__GET_PDF $@)
|
||||
[ ! $PDF ] && return 1
|
||||
|
||||
OPEN "$PDF"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
OPEN_PDF $@
|
||||
|
@ -1,14 +1,9 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/memo
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
OPEN_MEMO() {
|
||||
local MEMO_NAME=$(MEMO__LIST_ALL | FZF_TAIL 'select/create a memo')
|
||||
MAIN() {
|
||||
local MEMO_NAME=$(MEMO__LIST_ALL | FZF_USER_INPUT 'select/create a memo')
|
||||
[ ! "$MEMO_NAME" ] && ABORT
|
||||
|
||||
MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
|
||||
@ -26,6 +21,3 @@ OPEN_MEMO() {
|
||||
|
||||
EDIT "$MEMO_FILE"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
OPEN_MEMO $@
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use office/memo
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
DELETE_MEMO() {
|
||||
MAIN() {
|
||||
local MEMO_NAME=$(MEMO__LIST_ALL | FZF 'select a memo to delete')
|
||||
local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
|
||||
[ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || ABORT
|
||||
@ -28,6 +23,3 @@ DELETE_MEMO() {
|
||||
|| FAIL 1 "failed to remove memo '$MEMO_NAME'" \
|
||||
;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
DELETE_MEMO $@
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use redis
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
CURL_WITH_CACHE() {
|
||||
MAIN() {
|
||||
[ ! $TTL ] && TTL=10
|
||||
|
||||
[[ $(REDIS__ENABLED) -eq 0 ]] && {
|
||||
@ -46,7 +41,6 @@ CURL_WITH_CACHE() {
|
||||
echo $OUTPUT
|
||||
}
|
||||
|
||||
GET_URL_KEY() { echo "scwrypts:curl:$1" | sed 's/\s\+/+/g'; }
|
||||
|
||||
#####################################################################
|
||||
CURL_WITH_CACHE $@
|
||||
|
||||
GET_URL_KEY() { echo "scwrypts:curl:$1" | sed 's/\s\+/+/g'; }
|
||||
|
52
zsh/sanity-check
Executable file
52
zsh/sanity-check
Executable file
@ -0,0 +1,52 @@
|
||||
#!/bin/zsh
|
||||
#####################################################################
|
||||
|
||||
USAGE__options='
|
||||
-e, --exit-code desired exit code of the function (default "0")
|
||||
-f, --output-function one of the zsh/utils output functions (default "SUCCESS")
|
||||
-m, --message a message to display (default "Hello, World!")
|
||||
'
|
||||
|
||||
USAGE__description='
|
||||
a simple hello-world-style script which allows specific scwrypts
|
||||
conditions to be quickly emulated
|
||||
'
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local OUTPUT_FUNCTION=SUCCESS
|
||||
local EXIT_CODE=0
|
||||
local MESSAGE='Hello, world!'
|
||||
|
||||
ARGUMENT_REQUIRED() { ERROR "'$1' requires an argument"; }
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-e | --exit-code )
|
||||
EXIT_CODE="$2"
|
||||
[ $2 ] && shift 1 || ARGUMENT_REQUIRED
|
||||
;;
|
||||
-f | --output-function )
|
||||
OUTPUT_FUNCTION="$2"
|
||||
[ $2 ] && shift 1 || ARGUMENT_REQUIRED
|
||||
;;
|
||||
-m | --message )
|
||||
MESSAGE="$2"
|
||||
[ $2 ] && shift 1 || ARGUMENT_REQUIRED
|
||||
;;
|
||||
* ) ERROR "unknown argument '$1'" ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
CHECK_ERRORS
|
||||
|
||||
##########################################
|
||||
|
||||
[[ $OUTPUT_FUNCTION =~ ^FAIL$ ]] && FAIL $EXIT_CODE "$MESSAGE"
|
||||
|
||||
$OUTPUT_FUNCTION "$MESSAGE"
|
||||
return $EXIT_CODE
|
||||
}
|
57
zsh/scwrypts/configure
vendored
57
zsh/scwrypts/configure
vendored
@ -1,36 +1,33 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/meta
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
|
||||
|
||||
[ ! -f "$USER_CONFIG_OVERRIDES" ] && {
|
||||
STATUS 'first-time setup detected; creating local configuration override...'
|
||||
cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES"
|
||||
|
||||
EDIT $USER_CONFIG_OVERRIDES
|
||||
|
||||
STATUS 'attempting first-time build for virtual environments'
|
||||
SCWRYPTS__RUN --name scwrypts/virtualenv/update-all --group scwrypts --type zsh \
|
||||
&& SUCCESS 'finished updating virtualenvs' \
|
||||
|| WARNING 'unable to create one or more virtualenv (see above)' \
|
||||
;
|
||||
|
||||
REMINDER '
|
||||
in the future, you can use the following scwrypt to update required virtual
|
||||
environments (equivalent to "npm install" or "pip install -r requirements"):
|
||||
MAIN() {
|
||||
local USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
|
||||
|
||||
scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh
|
||||
'
|
||||
} || {
|
||||
EDIT "$USER_CONFIG_OVERRIDES"
|
||||
[ ! -f "$USER_CONFIG_OVERRIDES" ] && {
|
||||
STATUS 'first-time setup detected; creating local configuration override...'
|
||||
cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES"
|
||||
|
||||
EDIT $USER_CONFIG_OVERRIDES
|
||||
|
||||
STATUS 'attempting first-time build for virtual environments'
|
||||
SCWRYPTS__RUN --name scwrypts/virtualenv/update-all --group scwrypts --type zsh \
|
||||
&& SUCCESS 'finished updating virtualenvs' \
|
||||
|| WARNING 'unable to create one or more virtualenv (see above)' \
|
||||
;
|
||||
|
||||
REMINDER '
|
||||
in the future, you can use the following scwrypt to update required virtual
|
||||
environments (equivalent to "npm install" or "pip install -r requirements"):
|
||||
|
||||
scwrypts --name scwrypts/virtualenv/update-all --group scwrypts --type zsh
|
||||
'
|
||||
} || {
|
||||
EDIT "$USER_CONFIG_OVERRIDES"
|
||||
}
|
||||
|
||||
|
||||
SUCCESS 'saved new configuration'
|
||||
REMINDER 'changes which affect the hot-key plugin will require a ZSHRC reload'
|
||||
}
|
||||
|
||||
|
||||
SUCCESS 'saved new configuration'
|
||||
REMINDER 'changes which affect the hot-key plugin will require a ZSHRC reload'
|
||||
|
@ -1,38 +1,35 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/environment-files
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
PROMPT 'choose an environment to copy'
|
||||
TEMPLATE_ENV_NAME=$(SCWRYPTS__SELECT_ENV)
|
||||
[ ! $TEMPLATE_ENV_NAME ] && ABORT
|
||||
|
||||
STATUS "selected '$TEMPLATE_ENV_NAME'"
|
||||
|
||||
PROMPT 'enter new environment name'
|
||||
ENV_NAME=$(echo '' | FZF_HEAD 'new environment')
|
||||
[ ! $ENV_NAME ] && ABORT
|
||||
SCWRYPTS__GET_ENV_NAMES | grep -q $ENV_NAME && FAIL 1 "'$ENV_NAME' already exists"
|
||||
|
||||
for GROUP in ${SCWRYPTS_GROUPS[@]}
|
||||
do
|
||||
TEMPLATE_ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $TEMPLATE_ENV_NAME $GROUP 2>/dev/null)
|
||||
ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $ENV_NAME $GROUP 2>/dev/null)
|
||||
|
||||
STATUS "creating environment '$ENV_NAME'"
|
||||
cat "$TEMPLATE_ENV_FILE" \
|
||||
| sed 's/ # from.*//' \
|
||||
> "$ENV_FILE" \
|
||||
&& SUCCESS "created '$ENV_FILE'" \
|
||||
|| FAIL 2 "something went wrong creating '$ENV_FILE'"
|
||||
done
|
||||
|
||||
STATUS "synchronizing environments"
|
||||
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|
||||
&& SUCCESS "finished copy environment '$TEMPLATE_ENV_NAME > $ENV_NAME'" \
|
||||
|| FAIL 3 'error during synchronization of new environment (see above)' \
|
||||
;
|
||||
MAIN() {
|
||||
PROMPT 'choose an environment to copy'
|
||||
TEMPLATE_ENV_NAME=$(SCWRYPTS__SELECT_ENV)
|
||||
[ ! $TEMPLATE_ENV_NAME ] && ABORT
|
||||
|
||||
STATUS "selected '$TEMPLATE_ENV_NAME'"
|
||||
|
||||
PROMPT 'enter new environment name'
|
||||
ENV_NAME=$(echo '' | FZF_USER_INPUT 'new environment')
|
||||
[ ! $ENV_NAME ] && ABORT
|
||||
SCWRYPTS__GET_ENV_NAMES | grep -q $ENV_NAME && FAIL 1 "'$ENV_NAME' already exists"
|
||||
|
||||
for GROUP in ${SCWRYPTS_GROUPS[@]}
|
||||
do
|
||||
TEMPLATE_ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $TEMPLATE_ENV_NAME $GROUP 2>/dev/null)
|
||||
ENV_FILE=$(SCWRYPTS__GET_ENV_FILE $ENV_NAME $GROUP 2>/dev/null)
|
||||
|
||||
STATUS "creating environment '$ENV_NAME'"
|
||||
cat "$TEMPLATE_ENV_FILE" \
|
||||
| sed 's/ # from.*//' \
|
||||
> "$ENV_FILE" \
|
||||
&& SUCCESS "created '$ENV_FILE'" \
|
||||
|| FAIL 2 "something went wrong creating '$ENV_FILE'"
|
||||
done
|
||||
|
||||
STATUS "synchronizing environments"
|
||||
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|
||||
&& SUCCESS "finished copy environment '$TEMPLATE_ENV_NAME > $ENV_NAME'" \
|
||||
|| FAIL 3 'error during synchronization of new environment (see above)' \
|
||||
;
|
||||
}
|
||||
|
@ -1,36 +1,33 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/environment-files
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
PROMPT 'choose an environment to delete'
|
||||
ENV_NAME=$(SCWRYPTS__SELECT_ENV)
|
||||
[ ! $ENV_NAME ] && ABORT
|
||||
|
||||
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME))
|
||||
|
||||
STATUS "preparing to remove '$ENV_NAME'"
|
||||
|
||||
WARNING "
|
||||
the '$ENV_NAME' environment will be removed configured options
|
||||
and stored credentials will be lost forever:
|
||||
|
||||
$(echo $ENV_FILES | sed 's| /|\n - /|g; s/^/ - /')
|
||||
"
|
||||
|
||||
yN 'continue?' || ABORT
|
||||
|
||||
STATUS "removing environment"
|
||||
for ENV_FILE in ${ENV_FILES[@]}
|
||||
do
|
||||
rm "$ENV_FILE" \
|
||||
&& SUCCESS "removed '$ENV_FILE'" \
|
||||
|| ERROR "unable to remove '$ENV_FILE'; is it protected?" \
|
||||
;
|
||||
done
|
||||
|
||||
CHECK_ERRORS -n || FAIL 2 "some errors ocurred when cleaning up $ENV_NAME"
|
||||
MAIN() {
|
||||
PROMPT 'choose an environment to delete'
|
||||
ENV_NAME=$(SCWRYPTS__SELECT_ENV)
|
||||
[ ! $ENV_NAME ] && ABORT
|
||||
|
||||
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME))
|
||||
|
||||
STATUS "preparing to remove '$ENV_NAME'"
|
||||
|
||||
WARNING "
|
||||
the '$ENV_NAME' environment will be removed configured options
|
||||
and stored credentials will be lost forever:
|
||||
|
||||
$(echo $ENV_FILES | sed 's| /|\n - /|g; s/^/ - /')
|
||||
"
|
||||
|
||||
yN 'continue?' || ABORT
|
||||
|
||||
STATUS "removing environment"
|
||||
for ENV_FILE in ${ENV_FILES[@]}
|
||||
do
|
||||
rm "$ENV_FILE" \
|
||||
&& SUCCESS "removed '$ENV_FILE'" \
|
||||
|| ERROR "unable to remove '$ENV_FILE'; is it protected?" \
|
||||
;
|
||||
done
|
||||
|
||||
CHECK_ERRORS -n || FAIL 2 "some errors ocurred when cleaning up $ENV_NAME"
|
||||
}
|
||||
|
@ -1,45 +1,42 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/environment-files
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
[ $1 ] && ENV_NAME="$1"
|
||||
|
||||
[ ! $1 ] && {
|
||||
[ $SCWRYPTS_ENV ] \
|
||||
&& ENV_NAME=$SCWRYPTS_ENV \
|
||||
|| ENV_NAME=$(SCWRYPTS__SELECT_OR_CREATE_ENV)
|
||||
}
|
||||
[ ! $ENV_NAME ] && ABORT
|
||||
|
||||
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME 2>/dev/null))
|
||||
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'" \
|
||||
|| { ERROR "failed to create '$ENV_FILE'"; exit 1; }
|
||||
}
|
||||
|
||||
[ $CREATED ] && [[ $CREATED -gt 0 ]] && {
|
||||
STATUS "detected new environment files; performing sync" \
|
||||
&& SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|
||||
|| FAIL 1 "failure during sync for '$ENV_NAME'" \
|
||||
MAIN() {
|
||||
[ $1 ] && ENV_NAME="$1"
|
||||
|
||||
[ ! $1 ] && {
|
||||
[ $SCWRYPTS_ENV ] \
|
||||
&& ENV_NAME=$SCWRYPTS_ENV \
|
||||
|| ENV_NAME=$(SCWRYPTS__SELECT_OR_CREATE_ENV)
|
||||
}
|
||||
[ ! $ENV_NAME ] && ABORT
|
||||
|
||||
ENV_FILES=($(SCWRYPTS__GET_ENV_FILES $ENV_NAME 2>/dev/null))
|
||||
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'" \
|
||||
|| { ERROR "failed to create '$ENV_FILE'"; exit 1; }
|
||||
}
|
||||
|
||||
[ $CREATED ] && [[ $CREATED -gt 0 ]] && {
|
||||
STATUS "detected new environment files; performing sync" \
|
||||
&& SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|
||||
|| FAIL 1 "failure during sync for '$ENV_NAME'" \
|
||||
}
|
||||
;
|
||||
done
|
||||
|
||||
EDIT $ENV_FILES
|
||||
|
||||
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|
||||
|| FAIL 4 'failed to run environment sync' \
|
||||
;
|
||||
done
|
||||
|
||||
EDIT $ENV_FILES
|
||||
|
||||
SCWRYPTS__RUN --name scwrypts/environment/synchronize --group scwrypts --type zsh -- --no-prompt \
|
||||
|| FAIL 4 'failed to run environment sync' \
|
||||
;
|
||||
|
||||
SUCCESS "environment '$ENV_NAME' successfully modified"
|
||||
|
||||
SUCCESS "environment '$ENV_NAME' successfully modified"
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/environment-files
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
SYNCHRONIZE() {
|
||||
MAIN() {
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
@ -176,4 +171,4 @@ CLEANUP_ENVIRONMENT_FILE() {
|
||||
rm "$1.temp"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
#####################################################################
|
||||
|
@ -1,22 +1,20 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
cd $SCWRYPTS_ROOT
|
||||
|
||||
STATUS "Found $(ls $SCWRYPTS_LOG_PATH | wc -l) log files"
|
||||
WARNING "
|
||||
this will permanently clear all local cloud script logs found in
|
||||
'$SCWRYPTS_LOG_PATH'
|
||||
"
|
||||
|
||||
yN 'continue?' || ABORT
|
||||
|
||||
STATUS 'removing logfiles'
|
||||
rm -rf $SCWRYPTS_LOG_PATH/* \
|
||||
&& SUCCESS 'done' \
|
||||
|| { ERROR 'failed :c'; exit 2; }\
|
||||
;
|
||||
MAIN() {
|
||||
cd $SCWRYPTS_ROOT
|
||||
|
||||
STATUS "Found $(ls $SCWRYPTS_LOG_PATH | wc -l) log files"
|
||||
WARNING "
|
||||
this will permanently clear all local cloud script logs found in
|
||||
'$SCWRYPTS_LOG_PATH'
|
||||
"
|
||||
|
||||
yN 'continue?' || ABORT
|
||||
|
||||
STATUS 'removing logfiles'
|
||||
rm -rf $SCWRYPTS_LOG_PATH/* \
|
||||
&& SUCCESS 'done' \
|
||||
|| { ERROR 'failed :c'; exit 2; }\
|
||||
;
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
cd $SCWRYPTS_ROOT
|
||||
PROMPT 'select a script log'
|
||||
LOG_FILE=$(ls -t $SCWRYPTS_LOG_PATH | FZF 'logfile')
|
||||
[ ! $LOG_FILE ] && { ERROR 'user abort'; exit 1; }
|
||||
|
||||
STATUS 'opening logfile'
|
||||
LESS "$SCWRYPTS_LOG_PATH/$LOG_FILE"
|
||||
SUCCESS 'done'
|
||||
MAIN() {
|
||||
cd $SCWRYPTS_ROOT
|
||||
PROMPT 'select a script log'
|
||||
LOG_FILE=$(ls -t $SCWRYPTS_LOG_PATH | FZF 'logfile')
|
||||
[ ! $LOG_FILE ] && { ERROR 'user abort'; exit 1; }
|
||||
|
||||
STATUS 'opening logfile'
|
||||
LESS "$SCWRYPTS_LOG_PATH/$LOG_FILE"
|
||||
SUCCESS 'done'
|
||||
}
|
||||
|
@ -1,30 +1,27 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/virtualenv
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-g | --group ) ENV_GROUP="$2"; shift 1 ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ ! $ENV_GROUP ] && ENV_GROUP=scwrypts
|
||||
|
||||
ENV_TYPE=$(echo $AVAILABLE_VIRTUALENVS | sed 's/ \+/\n/' | FZF 'select an environment to refresh')
|
||||
[ ! $ENV_TYPE ] && ABORT
|
||||
|
||||
REMINDER "
|
||||
this will permanently remove all artifacts for the scwrypts $ENV_TYPE environment
|
||||
(safe unless you have put something important in $(GET_VIRTUALENV_PATH $ENV_GROUP $ENV_TYPE))
|
||||
"
|
||||
|
||||
Yn "drop and recreate $ENV_TYPE virtual environment?" || ABORT
|
||||
|
||||
REFRESH_VIRTUALENV $ENV_GROUP $ENV_TYPE
|
||||
MAIN() {
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-g | --group ) ENV_GROUP="$2"; shift 1 ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ ! $ENV_GROUP ] && ENV_GROUP=scwrypts
|
||||
|
||||
ENV_TYPE=$(echo $AVAILABLE_VIRTUALENVS | sed 's/ \+/\n/' | FZF 'select an environment to refresh')
|
||||
[ ! $ENV_TYPE ] && ABORT
|
||||
|
||||
REMINDER "
|
||||
this will permanently remove all artifacts for the scwrypts $ENV_TYPE environment
|
||||
(safe unless you have put something important in $(_VIRTUALENV__GET_PATH $ENV_GROUP $ENV_TYPE))
|
||||
"
|
||||
|
||||
Yn "drop and recreate $ENV_TYPE virtual environment?" || ABORT
|
||||
|
||||
REFRESH_VIRTUALENV $ENV_GROUP $ENV_TYPE
|
||||
}
|
||||
|
@ -1,25 +1,21 @@
|
||||
#!/bin/zsh
|
||||
echo hey
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/virtualenv
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
STATUS 'beginning update for all environments'
|
||||
|
||||
FAILED_COUNT=0
|
||||
|
||||
for ENV_GROUP in ${SCWRYPTS_GROUPS[@]}
|
||||
do
|
||||
for ENV_TYPE in ${AVAILABLE_VIRTUALENVS[@]}
|
||||
MAIN() {
|
||||
STATUS 'beginning update for all environments'
|
||||
|
||||
FAILED_COUNT=0
|
||||
|
||||
for ENV_GROUP in ${SCWRYPTS_GROUPS[@]}
|
||||
do
|
||||
UPDATE_VIRTUALENV $ENV_GROUP $ENV_TYPE || ((FAILED_COUNT+=1))
|
||||
for ENV_TYPE in ${AVAILABLE_VIRTUALENVS[@]}
|
||||
do
|
||||
UPDATE_VIRTUALENV $ENV_GROUP $ENV_TYPE || ((FAILED_COUNT+=1))
|
||||
done
|
||||
done
|
||||
done
|
||||
|
||||
[[ $FAILED_COUNT -eq 0 ]] \
|
||||
&& SUCCESS 'all environments up-to-date' \
|
||||
|| FAIL $FAILED_COUNT "failed to update $FAILED_COUNT more environment(s)"
|
||||
|
||||
[[ $FAILED_COUNT -eq 0 ]] \
|
||||
&& SUCCESS 'all environments up-to-date' \
|
||||
|| FAIL $FAILED_COUNT "failed to update $FAILED_COUNT more environment(s)"
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/config
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
EDIT "$CONFIG__USER_SETTINGS"
|
||||
|
||||
MAIN() {
|
||||
EDIT "$CONFIG__USER_SETTINGS"
|
||||
}
|
||||
|
@ -1,19 +1,16 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/config
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
SETUP_SYMLINKS() {
|
||||
MAIN() {
|
||||
while read SYMLINK
|
||||
do
|
||||
SETUP_SYMLINK $(echo $SYMLINK | awk '{print $1;}') $(echo $SYMLINK | awk '{print $2}')
|
||||
done < <(echo $SYMLINKS | sed -n '/^[^#]/p')
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
SETUP_SYMLINK() {
|
||||
[ ! $2 ] && FAIL 1 'must provide SOURCE_CONFIG and TARGET_CONFIG'
|
||||
|
||||
@ -21,7 +18,7 @@ SETUP_SYMLINK() {
|
||||
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'
|
||||
DEBUG 'SOURCE_CONFIG is not tracked; copying from TARGET_CONFIG'
|
||||
mkdir -p "$(dirname "$SOURCE_CONFIG")"
|
||||
cp "$TARGET_CONFIG" "$SOURCE_CONFIG"
|
||||
}
|
||||
@ -42,6 +39,3 @@ SETUP_SYMLINK() {
|
||||
|| FAIL 3 "failed to create link '$TARGET_CONFIG'" \
|
||||
;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
SETUP_SYMLINKS $@
|
||||
|
@ -1,13 +1,10 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=(tic)
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/config
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
SETUP_TERMINFO() {
|
||||
MAIN() {
|
||||
[ ! $TERMINFO_PATH ] && return 0
|
||||
[ ! -d $TERMINFO_PATH ] && FAIL 1 "TERMINFO_PATH='$TERMINFO_PATH' does not exist"
|
||||
|
||||
@ -22,6 +19,3 @@ SETUP_TERMINFO() {
|
||||
|
||||
CHECK_ERRORS
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
SETUP_TERMINFO $@
|
||||
|
@ -1,13 +1,10 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/meta
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
STATUS 'updating all config files and links'
|
||||
SCWRYPTS__RUN --name system/config/symlinks --group scwrypts --type zsh || exit 1
|
||||
SCWRYPTS__RUN --name system/config/terminfo --group scwrypts --type zsh || exit 2
|
||||
SUCCESS 'finished updating config files and links'
|
||||
MAIN() {
|
||||
STATUS 'updating all config files and links'
|
||||
SCWRYPTS__RUN --name system/config/symlinks --group scwrypts --type zsh || exit 1
|
||||
SCWRYPTS__RUN --name system/config/terminfo --group scwrypts --type zsh || exit 2
|
||||
SUCCESS 'finished updating config files and links'
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/meta
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-build $@
|
||||
|
||||
MAIN() {
|
||||
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-build $@
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/meta
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-pull $@
|
||||
|
||||
MAIN() {
|
||||
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --only-pull $@
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/packages/git
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
INSTALL() {
|
||||
MAIN() {
|
||||
local USAGE="
|
||||
usage: [...options...]
|
||||
|
||||
@ -71,7 +66,7 @@ INSTALL() {
|
||||
|
||||
[ ! $NAME ] && {
|
||||
NAME=$(echo $TARGET | sed 's/.*\///; s/\.git$//')
|
||||
INFO "using default name '$NAME'"
|
||||
DEBUG "using default name '$NAME'"
|
||||
}
|
||||
|
||||
[ -d "$PACKAGE_INSTALL_DIR/$NAME" ] && [[ $SKIP_PULL -eq 0 ]] && {
|
||||
@ -86,6 +81,3 @@ INSTALL() {
|
||||
[[ $SKIP_BUILD -eq 1 ]] && return 0
|
||||
BUILD
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
INSTALL $@
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use scwrypts/meta
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --update $@
|
||||
|
||||
MAIN() {
|
||||
SCWRYPTS__RUN --name system/packages/install --group scwrypts --type zsh -- --update $@
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/vim/vundle
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
EDIT "$VUNDLE__BUILD_DEFINITIONS"
|
||||
|
||||
MAIN() {
|
||||
EDIT "$VUNDLE__BUILD_DEFINITIONS"
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/vim/vundle
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
|
||||
PLUGIN_INSTALL() {
|
||||
MAIN() {
|
||||
[ -d "$HOME/.vim/bundle/Vundle.vim" ] || {
|
||||
mkdir -p "$HOME/.vim/bundle/"
|
||||
git clone https://github.com/VundleVim/Vundle.vim.git "$HOME/.vim/bundle/Vundle.vim"
|
||||
@ -16,6 +11,3 @@ PLUGIN_INSTALL() {
|
||||
VUNDLE__PLUGIN_INSTALL || return 1
|
||||
VUNDLE__REBUILD_PLUGINS || return 2
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
PLUGIN_INSTALL $@
|
||||
|
@ -1,9 +1,7 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
use system/vim/vundle
|
||||
|
||||
CHECK_ENVIRONMENT
|
||||
#####################################################################
|
||||
VUNDLE__REBUILD_PLUGINS $@
|
||||
|
||||
MAIN() {
|
||||
VUNDLE__REBUILD_PLUGINS $@
|
||||
}
|
||||
|
Reference in New Issue
Block a user