From e1f08d43ec8a94fc48d961019dc506384e282f3c Mon Sep 17 00:00:00 2001 From: Shmuel Raichman <22668282+shmuel-raichman@users.noreply.github.com> Date: Tue, 12 Jul 2022 18:59:02 +0300 Subject: [PATCH] Added - how to add kubectl completion with fzf --- Examples.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Examples.md b/Examples.md index 89241cf..038a62e 100644 --- a/Examples.md +++ b/Examples.md @@ -42,6 +42,7 @@ Table of Contents * [jrnl](#jrnl) * [tmux](#tmux) * [dictcc translation](#dictcc-translation) + * [kubectl](#kubectl) * Moving from other tools * [fzf as rofi replacement](#fzf-as-rofi-replacement) * [fzf as dmenu replacement](#fzf-as-dmenu-replacement) @@ -932,6 +933,44 @@ ALT-` key will split the current window and start fzf for the entire list of fil bind-key -n 'M-`' run "tmux split-window -p 40 'tmux send-keys -t #{pane_id} \"$(locate / | fzf -m | paste -sd\\ -)\"'" ``` +### kubectl +Add support for kubectl completion with fzf +```bash +# Tested kubectl version `v1.23.6` +# Make all kubectl completion fzf +command -v fzf >/dev/null 2>&1 && { + source <(kubectl completion bash | sed 's#"${requestComp}" 2>/dev/null#"${requestComp}" 2>/dev/null | head -n -1 | fzf --multi=0 #g') # setup autocomplete for istioctl +} +``` +Put this in your `.bashrc` insted of +```bash +source <(kubectl completion bash) +``` +It will source kubectl completion with fzf support +Examples: +```bash +# Will open fzf windows with k8s objects starting with `p` +kubectl get p + +# Will open fzf list of pods. +kubectl get pods +``` + +Notes: + +This will make all kubectl commands use fzf for completion.
+This was tested with: + +- [x] version `v1.23.6` +- [x] bash +- commands: + - [x] get + - [x] get pods + - [x] describe + - [x] describe pods + - [x] logs + + ### ASDF ```sh