Currently k8s CLI has not perfect bash completion for printing resources, like pods, svcs names.
Sometimes we need to copy & paste their names but this is very annoying when using CLI.
So, I add shortcut key for bash user and this is for helping to select k8s resources and exactly print to shell.
\<Ctrl+T> is for transposing last two characters.
But nobody use this shortcut a lot. ;)
So, You can replace \<Ctrl+T> key binding for custom action like example.
First you need to install fzf for selecting pod,svc,deployment
brew install fzf
Set this functions and binding key first
__kgaselect\_() {
local map=$(kubectl get all --show-labels=true --all-namespaces | grep -v '^NAMESPACE')
echo "${map}" | fzf -x -e +s --reverse --bind=left:page-up,right:page-down --no-mouse | awk '{print $2" --namespace "$1}'
}
__kgawidget\_() {
local selected="$(\_\_kga_select\_\_)"
READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"
READLINE_POINT=$(( READLINE_POINT + ${#selected} ))
}
bind ‘“\er”: redraw-current-line’
if [ $BASH_VERSINFO -gt 3 ]; then