Created
December 10, 2021 01:25
-
-
Save junegunn/f8cc9dac93604b17de9fcf9a521ea4b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
all-pods() { | |
FZF_DEFAULT_COMMAND=' | |
(echo CONTEXT NAMESPACE NAME READY STATUS RESTARTS AGE | |
for context in $(kubectl config get-contexts --no-headers -o name | sort); do | |
kubectl get pods --all-namespaces --no-headers --context "$context" | sed "s/^/${context%-context} /" | |
done) 2> /dev/null | column -t | |
' fzf --info=inline --layout=reverse --header-lines=1 --border \ | |
--prompt 'all-pods> ' \ | |
--header $'╱ Enter (kubectl exec) ╱ CTRL-O (open log in editor) ╱ CTRL-R (reload) ╱\n\n' \ | |
--bind ctrl-/:toggle-preview \ | |
--bind 'enter:execute:kubectl exec -it --context {1}-context --namespace {2} {3} -- bash > /dev/tty' \ | |
--bind 'ctrl-o:execute:${EDITOR:-vim} <(kubectl logs --context {1}-context --namespace {2} {3}) > /dev/tty' \ | |
--bind 'ctrl-r:reload:eval "$FZF_DEFAULT_COMMAND"' \ | |
--preview-window up:follow \ | |
--preview 'kubectl logs --follow --tail=100000 --context {1}-context --namespace {2} {3}' "$@" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment