feat(tmux): add support for fzf-tmux in interactive mode

This commit is contained in:
xero 2023-07-05 09:52:33 -04:00
parent 7560b8f04f
commit 1c6f516142
No known key found for this signature in database
GPG Key ID: 0DA7AB45AC1D0000
3 changed files with 9 additions and 4 deletions

View File

@ -50,7 +50,8 @@ Active namespace is "default".
If you have [`fzf`](https://github.com/junegunn/fzf) installed, you can also If you have [`fzf`](https://github.com/junegunn/fzf) installed, you can also
**interactively** select a context or cluster, or fuzzy-search by typing a few **interactively** select a context or cluster, or fuzzy-search by typing a few
characters. To learn more, read [interactive mode →](#interactive-mode) characters. To learn more, read [interactive mode →](#interactive-mode).
Additionally, if you are running under [`TMUX`](https://github.com/tmux/tmux), `fzf-tmux` will be used.
Both `kubectx` and `kubens` support <kbd>Tab</kbd> completion on bash/zsh/fish Both `kubectx` and `kubens` support <kbd>Tab</kbd> completion on bash/zsh/fish
shells to help with long context names. You don't have to remember full context shells to help with long context names. You don't have to remember full context

View File

@ -113,9 +113,11 @@ switch_context() {
choose_context_interactive() { choose_context_interactive() {
local choice local choice
local FZF='fzf'
[[ -n "${TMUX-}" ]] && FZF="fzf-tmux"
choice="$(_KUBECTX_FORCE_COLOR=1 \ choice="$(_KUBECTX_FORCE_COLOR=1 \
FZF_DEFAULT_COMMAND="${SELF_CMD}" \ FZF_DEFAULT_COMMAND="${SELF_CMD}" \
fzf --ansi --no-preview || true)" ${FZF} --ansi --no-preview || true)"
if [[ -z "${choice}" ]]; then if [[ -z "${choice}" ]]; then
echo 2>&1 "error: you did not choose any of the options" echo 2>&1 "error: you did not choose any of the options"
exit 1 exit 1

4
kubens
View File

@ -114,9 +114,11 @@ choose_namespace_interactive() {
fi fi
local choice local choice
local FZF='fzf'
[[ -n "${TMUX-}" ]] && FZF="fzf-tmux"
choice="$(_KUBECTX_FORCE_COLOR=1 \ choice="$(_KUBECTX_FORCE_COLOR=1 \
FZF_DEFAULT_COMMAND="${SELF_CMD}" \ FZF_DEFAULT_COMMAND="${SELF_CMD}" \
fzf --ansi --no-preview || true)" ${FZF} --ansi --no-preview || true)"
if [[ -z "${choice}" ]]; then if [[ -z "${choice}" ]]; then
echo 2>&1 "error: you did not choose any of the options" echo 2>&1 "error: you did not choose any of the options"
exit 1 exit 1