Skip to content

Instantly share code, notes, and snippets.

@Eun
Last active February 11, 2020 08:57
Show Gist options
  • Save Eun/65a916fc71e7bee48c87a2e443e11b12 to your computer and use it in GitHub Desktop.
Save Eun/65a916fc71e7bee48c87a2e443e11b12 to your computer and use it in GitHub Desktop.
kubesh
#!/bin/bash
if [ ${#@} -lt 1 ]; then
echo "usage: kubesh <pod> [shell]"
exit 1
fi
SHELL="sh"
if [ ${#@} -gt 1 ]; then
SHELL=${@:2}
fi
kubectl exec -ti ${1} ${SHELL}
# completion for kubesh
# (put in ~/.config/fish/completions)
function __kubesh_completion
if test -n "$__kubesh_completion_cache_valid_until"; and test $__kubesh_completion_cache_valid_until -gt (date --utc +"%s")
string join \n $__kubesh_completion_cache_content
return
end
set -g __kubesh_completion_cache_valid_until (math (date --utc +"%s") + 10)
set -g __kubesh_completion_cache_content (kubectl get pods -o=jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}')
string join \n $__kubesh_completion_cache_content
end
complete -f -c kubesh -a '(__kubesh_completion)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment