2023-02-22 01:44:27 +00:00
|
|
|
NO_EXPORT_CONFIG=1 source "${0:a:h}/zsh/lib/import.driver.zsh" || return 42
|
|
|
|
|
2022-04-28 22:09:23 +00:00
|
|
|
#####################################################################
|
2023-02-22 01:44:27 +00:00
|
|
|
SCWRYPTS__ZSH_PLUGIN() {
|
|
|
|
local SCWRYPT_SELECTION=$(SCWRYPTS__GET_AVAILABLE_SCWRYPTS | FZF 'select a script' --header-lines 1)
|
|
|
|
local NAME
|
|
|
|
local TYPE
|
|
|
|
local GROUP
|
2023-12-12 00:07:09 +00:00
|
|
|
LBUFFER= RBUFFER=
|
2023-02-22 01:44:27 +00:00
|
|
|
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
|
|
|
|
|
|
|
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
2022-04-28 22:09:23 +00:00
|
|
|
|
|
|
|
which scwrypts >/dev/null 2>&1\
|
|
|
|
&& RBUFFER="scwrypts" || RBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
|
|
|
|
2023-12-12 00:07:09 +00:00
|
|
|
RBUFFER+=" --name $NAME --group $GROUP --type $TYPE --verbose"
|
2022-04-28 22:09:23 +00:00
|
|
|
zle accept-line
|
|
|
|
}
|
2022-05-24 16:26:05 +00:00
|
|
|
|
2023-02-22 01:44:27 +00:00
|
|
|
zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
|
2022-04-28 22:09:23 +00:00
|
|
|
bindkey $SCWRYPTS_SHORTCUT scwrypts
|
|
|
|
|
2023-12-12 00:07:09 +00:00
|
|
|
#####################################################################
|
|
|
|
SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
|
|
|
local SCWRYPT_SELECTION=$(SCWRYPTS__GET_AVAILABLE_SCWRYPTS | FZF 'select a script' --header-lines 1)
|
|
|
|
local NAME
|
|
|
|
local TYPE
|
|
|
|
local GROUP
|
|
|
|
LBUFFER= RBUFFER=
|
|
|
|
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
|
|
|
|
|
|
|
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
|
|
|
|
|
|
|
scwrypts --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
|
|
|
|
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-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
|
|
|
|
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
|
|
|
|
|
2022-04-28 22:09:23 +00:00
|
|
|
#####################################################################
|
2023-02-22 01:44:27 +00:00
|
|
|
SCWRYPTS__ZSH_PLUGIN_ENV() {
|
2022-04-28 22:09:23 +00:00
|
|
|
local RESET='reset'
|
|
|
|
local SELECTED=$(\
|
2023-02-22 01:44:27 +00:00
|
|
|
{ [ $SCWRYPTS_ENV ] && echo $RESET; SCWRYPTS__GET_ENV_NAMES; } \
|
|
|
|
| FZF 'select an environment' \
|
2022-04-28 22:09:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
zle clear-command-line
|
|
|
|
[ $SELECTED ] && {
|
|
|
|
[[ $SELECTED =~ ^$RESET$ ]] \
|
|
|
|
&& RBUFFER='unset SCWRYPTS_ENV' \
|
2022-05-24 16:26:05 +00:00
|
|
|
|| RBUFFER="export SCWRYPTS_ENV=$SELECTED"
|
2022-04-28 22:09:23 +00:00
|
|
|
}
|
|
|
|
zle accept-line
|
|
|
|
}
|
2022-05-24 16:26:05 +00:00
|
|
|
|
2023-02-22 01:44:27 +00:00
|
|
|
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
|
2022-04-28 22:09:23 +00:00
|
|
|
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
|