yage
6fe5b8e26a
===================================================================== DEPRECATION REMINDER! The following functions and APIS are no longer available: - FZF_HEAD : use FZF as a drop-in replacement - FZF_TAIL : use FZF as a drop-in replacement - SCWRYPTS__GET_RUNSTRING__zsh_v3 : upgrade to zsh/scwrypts v4 runstrings --- Bug Fixes ---------------------------- - removed legacy INFO references in plugins/kubectl - the zsh-builder plugin (CTRL+Y) now show clean helpdocs (no more visual terminal artifacts) --- New Features ------------------------- - differentiate manual / managed versions of scwrypts in versioning; this will prevent 'scwrypts --update' from operating against managed installations - created SCWRYPTS__GET_RUNSTRING__zsh__generic to provide an easy way to write custom runstrings; this will do all the nice things default zsh/scwrypts v4 do (multiflag separation, help flag injection, USAGE definitions, and required MAIN() {} wrapper).
43 lines
1.2 KiB
Bash
43 lines
1.2 KiB
Bash
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 ]
|
|
}
|