scwrypts/zsh/lib/config.zsh

96 lines
2.9 KiB
Bash
Raw Normal View History

v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
[[ $__SCWRYPT -eq 1 ]] && return 0
#####################################################################
# Apparently MacOS puts ALL of the homebrew stuff inside of a top level git repository
# with bizarre git ignores; so:
# - USE the git root if it's a manual install...
# - UNLESS that git root is just the $(brew --prefix)
SCWRYPTS_ROOT="$(cd -- ${0:a:h}; git rev-parse --show-toplevel 2>/dev/null | grep -v "^$(brew --prefix 2>/dev/null)$")"
v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
[ $SCWRYPTS_ROOT ] && [ -d "$SCWRYPTS_ROOT" ] \
|| SCWRYPTS_ROOT="$(echo "${0:a:h}" | sed -n 's|\(share/scwrypts\).*$|\1|p')"
[ $SCWRYPTS_ROOT ] && [ -d "$SCWRYPTS_ROOT" ] || {
echo "cannot determine scwrypts root path for current installation; aborting"
exit 1
}
export SCWRYPTS_ROOT__scwrypts="$SCWRYPTS_ROOT"
[ -f "$SCWRYPTS_ROOT__scwrypts/MANAGED_BY" ] \
&& export SCWRYPTS_INSTALLATION_TYPE=$(cat "$SCWRYPTS_ROOT__scwrypts/MANAGED_BY") \
|| export SCWRYPTS_INSTALLATION_TYPE=manual \
;
v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
#####################################################################
DEFAULT_CONFIG="$SCWRYPTS_ROOT__scwrypts/zsh/lib/config.user.zsh"
v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
source "$DEFAULT_CONFIG"
USER_CONFIG_OVERRIDES="$SCWRYPTS_CONFIG_PATH/config.zsh"
[ ! -f "$USER_CONFIG_OVERRIDES" ] && {
mkdir -p $(dirname "$USER_CONFIG_OVERRIDES")
cp "$DEFAULT_CONFIG" "$USER_CONFIG_OVERRIDES"
}
source "$USER_CONFIG_OVERRIDES"
mkdir -p \
"$SCWRYPTS_CONFIG_PATH" \
"$SCWRYPTS_DATA_PATH" \
"$SCWRYPTS_ENV_PATH" \
"$SCWRYPTS_LOG_PATH" \
"$SCWRYPTS_OUTPUT_PATH" \
;
v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
export \
SCWRYPTS_GROUPS \
SCWRYPTS_CONFIG_PATH \
SCWRYPTS_DATA_PATH \
SCWRYPTS_SHORTCUT \
SCWRYPTS_ENV_SHORTCUT \
SCWRYPTS_LOG_PATH \
SCWRYPTS_OUTPUT_PATH \
;
source "$SCWRYPTS_ROOT/scwrypts.scwrypts.zsh" \
v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
|| FAIL 69 'failed to set up scwrypts group; aborting'
#####################################################################
for plugin in $(ls $SCWRYPTS_ROOT__scwrypts/plugins)
do
[[ $(eval 'echo $SCWRYPTS_PLUGIN_ENABLED__'$plugin) -eq 1 ]] && {
source "$SCWRYPTS_ROOT/plugins/$plugin/$plugin.scwrypts.zsh"
}
done
#####################################################################
for GROUP_LOADER in $(env | sed -n 's/^SCWRYPTS_GROUP_LOADER__[a-z_]\+=//p')
do
[ -f "$GROUP_LOADER" ] && source "$GROUP_LOADER"
done
: \
&& [ ! "$SCWRYPTS_AUTODETECT_GROUP_BASEDIR" ] \
&& [ $GITHUB_WORKSPACE ] \
&& [ ! $SCWRYPTS_GITHUB_NO_AUTOLOAD ] \
&& SCWRYPTS_AUTODETECT_GROUP_BASEDIR="$GITHUB_WORKSPACE" \
;
[ "$SCWRYPTS_AUTODETECT_GROUP_BASEDIR" ] && [ -d "$SCWRYPTS_AUTODETECT_GROUP_BASEDIR" ] && {
for GROUP_LOADER in $(find "$SCWRYPTS_AUTODETECT_GROUP_BASEDIR" -type f -name \*scwrypts.zsh)
do
[ -f "$GROUP_LOADER" ] && source "$GROUP_LOADER"
done
}
#####################################################################
SCWRYPTS_GROUPS=(scwrypts $(echo $SCWRYPTS_GROUPS | sed 's/\s\+/\n/g' | sort -u | grep -v '^scwrypts$'))
v3.0.0 "The Great Overhaul" ===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
2023-02-22 01:44:27 +00:00
#####################################################################
__SCWRYPT=1 # arbitrary; indicates currently inside a scwrypt