v4.4.0
===================================================================== Increased non-scwrypts-runtime compatibility and improved clarity in user environments after sourcing the scwrypts.plugin.zsh. --- New Features ------------------------- - added experimental support for --output json - added 'scwrypts --list-groups' to output the SCWRYPTS_GROUPS value - added 'scwrypts --config' to be `eval`-ed in non-scwrypts-runtime zsh --- Changes ------------------------------ - removed config variables which pertained to old scwrypts - removed deprecated --no-log - cleaned up environment requirements and improved import saftey for scwrypts.plugin.zsh; scwrypts is now *required* on $PATH in order to work - refactored group configuration to match external group configuration (configuration now in scwrypts.scwrypts.zsh rather than zsh/lib/config.group.zsh) - plugins/kubectl now forces an unalias of `f` (for fluxcd) on load - the 'use' command now supports the '-c' short flag for ease of quick use - upgraded max supported python version to 3.12; dropped support for python 3.9 (>3.10 required) - remove old references to SCWRYPTS_ROOT in favour of SCWRYPTS_ROOT__scwrypts - SCWRYPTS_LOG_LEVEL setting is now forwarded when using the SCWRYPTS__RUN meta execution function
This commit is contained in:
+69
-54
@@ -1,82 +1,97 @@
|
||||
#
|
||||
# typically you do not need to reload this plugin in a single session;
|
||||
# if for some reason you do, you can run the following command and
|
||||
# source this file again
|
||||
#
|
||||
# unset __SCWRYPTS_PLUGIN_LOADED
|
||||
#
|
||||
[[ $__SCWRYPTS_PLUGIN_LOADED =~ true ]] && return 0
|
||||
|
||||
#####################################################################
|
||||
|
||||
: \
|
||||
&& command -v scwrypts &>/dev/null \
|
||||
&& source "$(scwrypts --root)/zsh/lib/import.driver.zsh" \
|
||||
&& unset __SCWRYPT \
|
||||
&& eval "$(scwrypts --config)" \
|
||||
|| {
|
||||
echo 'scwrypts must be in PATH and properly configured; skipping zsh plugin setup' >&2
|
||||
return 0
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__ZSH_PLUGIN() {
|
||||
local SCWRYPT_SELECTION=$(scwrypts --list | FZF 'select a script' --header-lines 1)
|
||||
local NAME
|
||||
local TYPE
|
||||
local GROUP
|
||||
__SCWRYPTS_PARSE() {
|
||||
SCWRYPT_SELECTION=$(scwrypts --list | fzf --prompt 'select a script : ' --header-lines 1)
|
||||
LBUFFER= RBUFFER=
|
||||
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
||||
[ $SCWRYPT_SELECTION ] || return 1
|
||||
|
||||
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
||||
NAME=$(echo "$SCWRYPT_SELECTION" | awk '{print $1;}')
|
||||
TYPE=$(echo "$SCWRYPT_SELECTION" | awk '{print $2;}')
|
||||
GROUP=$(echo "$SCWRYPT_SELECTION" | awk '{print $3;}')
|
||||
|
||||
which scwrypts >/dev/null 2>&1\
|
||||
&& RBUFFER="scwrypts" || RBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
||||
|
||||
RBUFFER+=" --name $NAME --group $GROUP --type $TYPE"
|
||||
zle accept-line
|
||||
[ $NAME ] && [ $TYPE ] && [ $GROUP ]
|
||||
}
|
||||
|
||||
zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
|
||||
bindkey $SCWRYPTS_SHORTCUT scwrypts
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
||||
local SCWRYPT_SELECTION=$(scwrypts --list | FZF 'select a script' --header-lines 1)
|
||||
echo $SCWRYPT_SELECTION >&2
|
||||
local NAME
|
||||
local TYPE
|
||||
local GROUP
|
||||
LBUFFER= RBUFFER=
|
||||
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
||||
[ $SCWRYPTS_SHORTCUT ] && {
|
||||
SCWRYPTS__ZSH_PLUGIN() {
|
||||
local SCWRYPT_SELECTION NAME TYPE GROUP
|
||||
__SCWRYPTS_PARSE || { zle accept-line; return 0; }
|
||||
|
||||
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
||||
|
||||
scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
|
||||
RBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP"
|
||||
zle accept-line
|
||||
return 0
|
||||
}
|
||||
echo
|
||||
|
||||
zle reset-prompt
|
||||
which scwrypts >/dev/null 2>&1\
|
||||
&& LBUFFER="scwrypts" || LBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
||||
|
||||
LBUFFER+=" --name $NAME --group $GROUP --type $TYPE -- "
|
||||
zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
|
||||
bindkey $SCWRYPTS_SHORTCUT scwrypts
|
||||
unset SCWRYPTS_SHORTCUT
|
||||
}
|
||||
|
||||
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
|
||||
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
|
||||
|
||||
#####################################################################
|
||||
|
||||
SCWRYPTS__ZSH_PLUGIN_ENV() {
|
||||
local RESET='reset'
|
||||
local SELECTED=$(\
|
||||
{ [ $SCWRYPTS_ENV ] && echo $RESET; SCWRYPTS__GET_ENV_NAMES; } \
|
||||
| FZF 'select an environment' \
|
||||
)
|
||||
[ $SCWRYPTS_BUILDER_SHORTCUT ] && {
|
||||
SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
||||
local SCWRYPT_SELECTION NAME TYPE GROUP
|
||||
__SCWRYPTS_PARSE || { echo >&2; zle accept-line; return 0; }
|
||||
echo $SCWRYPT_SELECTION >&2
|
||||
|
||||
zle clear-command-line
|
||||
[ $SELECTED ] && {
|
||||
[[ $SELECTED =~ ^$RESET$ ]] \
|
||||
&& RBUFFER='unset SCWRYPTS_ENV' \
|
||||
|| RBUFFER="export SCWRYPTS_ENV=$SELECTED"
|
||||
scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
|
||||
zle accept-line
|
||||
return 0
|
||||
}
|
||||
echo
|
||||
|
||||
zle reset-prompt
|
||||
LBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP -- "
|
||||
}
|
||||
zle accept-line
|
||||
|
||||
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
|
||||
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
|
||||
unset SCWRYPTS_BUILDER_SHORTCUT
|
||||
}
|
||||
|
||||
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
|
||||
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
|
||||
#####################################################################
|
||||
|
||||
[ $SCWRYPTS_ENV_SHORTCUT ] && {
|
||||
SCWRYPTS__ZSH_PLUGIN_ENV() {
|
||||
local RESET='reset'
|
||||
local SELECTED=$(\
|
||||
{ [ $SCWRYPTS_ENV ] && echo $RESET; scwrypts --list-envs; } \
|
||||
| fzf --prompt 'select an environment : ' \
|
||||
)
|
||||
|
||||
zle clear-command-line
|
||||
[ $SELECTED ] && {
|
||||
[[ $SELECTED =~ ^$RESET$ ]] \
|
||||
&& RBUFFER='unset SCWRYPTS_ENV' \
|
||||
|| RBUFFER="export SCWRYPTS_ENV=$SELECTED"
|
||||
}
|
||||
zle accept-line
|
||||
}
|
||||
|
||||
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
|
||||
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
|
||||
unset SCWRYPTS_ENV_SHORTCUT
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
__SCWRYPTS_PLUGIN_LOADED=true
|
||||
|
||||
Reference in New Issue
Block a user