File tree Expand file tree Collapse file tree 1 file changed +26
-12
lines changed
Expand file tree Collapse file tree 1 file changed +26
-12
lines changed Original file line number Diff line number Diff line change @@ -6,17 +6,22 @@ debug() {
66
77print-example () {
88 declare res=$1 pattern=$2
9- SELF=${BASH_SOURCE}
10- [[ -L $SELF ]] && SELF=$( readlink ${SELF} )
11- dir=$( dirname $SELF )
9+
10+ dir=$( dirname $( readlink $BASH_SOURCE ) )
1211 debug " dir=${dir} "
1312
13+ command fzf --version > /dev/null && FZF_INSTALLED=true
14+
1415 if [[ $res == " " ]]; then
15- PS3=" Resource Type: "
16- select res in [A-LN-Z][a-z]* ; do
17- debug " res type choosen: ${res} "
18- break
19- done
16+ if [[ $FZF_INSTALLED ]]; then
17+ res=$( cd ${dir} ; ls -1 $dir | grep -v kubectl-examples | fzf -e --prompt=" Resource Type>" )
18+ else
19+ PS3=" Resource Type: "
20+ select res in $( ls -1 $dir | grep -v kubectl-examples) ; do
21+ debug " res type choosen: ${res} "
22+ break
23+ done
24+ fi
2025 fi
2126
2227 # resorce names can be abreviated
@@ -39,10 +44,19 @@ print-example() {
3944 * )
4045 debug " multiple choice"
4146 PS3=" Yaml example: "
42- select yaml in ${dir} /${res} /** /* ${pattern} * .yaml; do
43- debug " YAML selected: ${yaml} "
44- break
45- done
47+ if [[ $FZF_INSTALLED ]]; then
48+ yaml=$(
49+ cd ${dir} /${res}
50+ ls -1 ** /* ${pattern} * .yaml \
51+ | fzf -e --preview=' cat {}'
52+ )
53+ yaml=" ${dir} /${res} /${yaml} "
54+ else
55+ select yaml in ${dir} /${res} /** /* ${pattern} * .yaml; do
56+ debug " YAML selected: ${yaml} "
57+ break
58+ done
59+ fi
4660 ;;
4761 esac
4862
You can’t perform that action at this time.
0 commit comments