my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.9 KiB

3 years ago
  1. # ---------------------------------------------------------- #
  2. # Aliases and Completions for MicroK8s (https://microk8s.io) #
  3. # Author: Shaun Tabone (https://github.com/xontab) #
  4. # ---------------------------------------------------------- #
  5. # Helper function to cache and load completions
  6. _microk8s_cache_completion() {
  7. local cache="${ZSH_CACHE_DIR}/microk8s_$(echo $1)_completion"
  8. if [[ ! -f $cache ]]; then
  9. $2 $cache
  10. fi
  11. [[ -f $cache ]] && source $cache
  12. }
  13. # ---------------------------------------------------------- #
  14. # microk8s.enable #
  15. # ALIAS: me #
  16. # ---------------------------------------------------------- #
  17. _microk8s_enable_get_command_list() {
  18. microk8s.enable --help | tail -n +7 | awk '{$1=$1;print}'
  19. }
  20. _microk8s_enable() {
  21. compadd -X "MicroK8s Addons" $(_microk8s_enable_get_command_list)
  22. }
  23. compdef _microk8s_enable microk8s.enable
  24. alias me='microk8s.enable'
  25. # ---------------------------------------------------------- #
  26. # microk8s.disable #
  27. # ALIAS: mdi #
  28. # ---------------------------------------------------------- #
  29. _microk8s_disable_get_command_list() {
  30. microk8s.disable --help | tail -n +7 | awk '{$1=$1;print}'
  31. }
  32. _microk8s_disable() {
  33. compadd -X "MicroK8s Addons" $(_microk8s_disable_get_command_list)
  34. }
  35. compdef _microk8s_disable microk8s.disable
  36. alias mdi='microk8s.disable'
  37. # ---------------------------------------------------------- #
  38. # microk8s.kubectl #
  39. # ALIAS: mk #
  40. # ---------------------------------------------------------- #
  41. _microk8s_kubectl_completion() {
  42. if [ $commands[microk8s.kubectl] ]; then
  43. microk8s.kubectl 2>/dev/null >/dev/null && microk8s.kubectl completion zsh | sed 's/__start_kubectl kubectl/__start_kubectl microk8s.kubectl/g' >$1
  44. fi
  45. }
  46. _microk8s_cache_completion 'kubectl' _microk8s_kubectl_completion
  47. alias mk='microk8s.kubectl'
  48. # ---------------------------------------------------------- #
  49. # microk8s.helm #
  50. # ALIAS: mh #
  51. # ---------------------------------------------------------- #
  52. _microk8s_helm_completion() {
  53. if [ $commands[microk8s.helm] ]; then
  54. microk8s.helm completion zsh | sed 's/__start_helm helm/__start_helm microk8s.helm/g' >$1
  55. fi
  56. }
  57. _microk8s_cache_completion 'helm' _microk8s_helm_completion
  58. alias mh='microk8s.helm'
  59. # ---------------------------------------------------------- #
  60. # Other Aliases #
  61. # ---------------------------------------------------------- #
  62. alias mco='microk8s.config'
  63. alias mct='microk8s.ctr'
  64. alias mis='microk8s.istio'
  65. alias mst='microk8s.start'
  66. alias msts='microk8s.status'
  67. alias msp='microk8s.stop'