mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-08-18 15:26:57 +00:00
feat(tmux): add support for fzf-tmux in interactive mode
This commit is contained in:
parent
7560b8f04f
commit
1c6f516142
@ -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
|
||||||
@ -196,7 +197,7 @@ Depending on your setup, you might or might not need to call `compinit` or
|
|||||||
`autoload -U compinit && compinit` in your `~/.zshrc` after you load the Plugins
|
`autoload -U compinit && compinit` in your `~/.zshrc` after you load the Plugins
|
||||||
file. If you use [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh), load the
|
file. If you use [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh), load the
|
||||||
completions before you load `oh-my-zsh` because `oh-my-zsh` will call
|
completions before you load `oh-my-zsh` because `oh-my-zsh` will call
|
||||||
`compinit`.
|
`compinit`.
|
||||||
|
|
||||||
#### Completion scripts for plain `zsh`
|
#### Completion scripts for plain `zsh`
|
||||||
|
|
||||||
|
4
kubectx
4
kubectx
@ -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
4
kubens
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user