cleaned up environment requirements for zsh plugin
This commit is contained in:
parent
71ba353fab
commit
9288e6642b
@ -2,47 +2,44 @@
|
|||||||
|
|
||||||
: \
|
: \
|
||||||
&& command -v scwrypts &>/dev/null \
|
&& command -v scwrypts &>/dev/null \
|
||||||
&& source "$(scwrypts --root)/zsh/lib/import.driver.zsh" \
|
&& eval "$(scwrypts --config)" \
|
||||||
&& unset __SCWRYPT \
|
|
||||||
|| {
|
|| {
|
||||||
echo 'scwrypts must be in PATH and properly configured; skipping zsh plugin setup' >&2
|
echo 'scwrypts must be in PATH and properly configured; skipping zsh plugin setup' >&2
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__SCWRYPTS_PARSE() {
|
||||||
|
SCWRYPT_SELECTION=$(scwrypts --list | fzf --prompt 'select a script : ' --header-lines 1)
|
||||||
|
LBUFFER= RBUFFER=
|
||||||
|
[ $SCWRYPT_SELECTION ] || return 1
|
||||||
|
|
||||||
|
NAME=$(echo "$SCWRYPT_SELECTION" | awk '{print $1;}')
|
||||||
|
TYPE=$(echo "$SCWRYPT_SELECTION" | awk '{print $2;}')
|
||||||
|
GROUP=$(echo "$SCWRYPT_SELECTION" | awk '{print $3;}')
|
||||||
|
|
||||||
|
[ $NAME ] && [ $TYPE ] && [ $GROUP ]
|
||||||
|
}
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
SCWRYPTS__ZSH_PLUGIN() {
|
SCWRYPTS__ZSH_PLUGIN() {
|
||||||
local SCWRYPT_SELECTION=$(scwrypts --list | FZF 'select a script' --header-lines 1)
|
local SCWRYPT_SELECTION NAME TYPE GROUP
|
||||||
local NAME
|
__SCWRYPTS_PARSE || { zle accept-line; return 0; }
|
||||||
local TYPE
|
|
||||||
local GROUP
|
|
||||||
LBUFFER= RBUFFER=
|
|
||||||
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
|
||||||
|
|
||||||
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
RBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP"
|
||||||
|
|
||||||
which scwrypts >/dev/null 2>&1\
|
|
||||||
&& RBUFFER="scwrypts" || RBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
|
||||||
|
|
||||||
RBUFFER+=" --name $NAME --group $GROUP --type $TYPE"
|
|
||||||
zle accept-line
|
zle accept-line
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
|
zle -N scwrypts SCWRYPTS__ZSH_PLUGIN
|
||||||
bindkey $SCWRYPTS_SHORTCUT scwrypts
|
bindkey $SCWRYPTS_SHORTCUT scwrypts
|
||||||
|
unset SCWRYPTS_SHORTCUT
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
||||||
local SCWRYPT_SELECTION=$(scwrypts --list | FZF 'select a script' --header-lines 1)
|
local SCWRYPT_SELECTION NAME TYPE GROUP
|
||||||
|
__SCWRYPTS_PARSE || { echo >&2; zle accept-line; return 0; }
|
||||||
echo $SCWRYPT_SELECTION >&2
|
echo $SCWRYPT_SELECTION >&2
|
||||||
local NAME
|
|
||||||
local TYPE
|
|
||||||
local GROUP
|
|
||||||
LBUFFER= RBUFFER=
|
|
||||||
[ ! $SCWRYPT_SELECTION ] && { zle accept-line; return 0; }
|
|
||||||
|
|
||||||
SCWRYPTS__SEPARATE_SCWRYPT_SELECTION $SCWRYPT_SELECTION
|
|
||||||
|
|
||||||
scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
|
scwrypts -n --name $NAME --group $GROUP --type $TYPE -- --help >&2 || {
|
||||||
zle accept-line
|
zle accept-line
|
||||||
@ -51,22 +48,20 @@ SCWRYPTS__ZSH_BUILDER_PLUGIN() {
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
zle reset-prompt
|
zle reset-prompt
|
||||||
which scwrypts >/dev/null 2>&1\
|
LBUFFER="scwrypts --name $NAME --type $TYPE --group $GROUP -- "
|
||||||
&& LBUFFER="scwrypts" || LBUFFER="$SCWRYPTS_ROOT/scwrypts"
|
|
||||||
|
|
||||||
LBUFFER+=" --name $NAME --group $GROUP --type $TYPE -- "
|
|
||||||
}
|
}
|
||||||
|
|
||||||
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
|
zle -N scwrypts-builder SCWRYPTS__ZSH_BUILDER_PLUGIN
|
||||||
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
|
bindkey $SCWRYPTS_BUILDER_SHORTCUT scwrypts-builder
|
||||||
|
unset SCWRYPTS_BUILDER_SHORTCUT
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
SCWRYPTS__ZSH_PLUGIN_ENV() {
|
SCWRYPTS__ZSH_PLUGIN_ENV() {
|
||||||
local RESET='reset'
|
local RESET='reset'
|
||||||
local SELECTED=$(\
|
local SELECTED=$(\
|
||||||
{ [ $SCWRYPTS_ENV ] && echo $RESET; SCWRYPTS__GET_ENV_NAMES; } \
|
{ [ $SCWRYPTS_ENV ] && echo $RESET; scwrypts --list-envs; } \
|
||||||
| FZF 'select an environment' \
|
| fzf --prompt 'select an environment : ' \
|
||||||
)
|
)
|
||||||
|
|
||||||
zle clear-command-line
|
zle clear-command-line
|
||||||
@ -80,3 +75,6 @@ SCWRYPTS__ZSH_PLUGIN_ENV() {
|
|||||||
|
|
||||||
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
|
zle -N scwrypts-setenv SCWRYPTS__ZSH_PLUGIN_ENV
|
||||||
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
|
bindkey $SCWRYPTS_ENV_SHORTCUT scwrypts-setenv
|
||||||
|
unset SCWRYPTS_ENV_SHORTCUT
|
||||||
|
|
||||||
|
#####################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user