Skip to content

Instantly share code, notes, and snippets.

@iocanel
Last active March 25, 2020 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iocanel/5fd718aece7958246fc72ae0670f5321 to your computer and use it in GitHub Desktop.
Save iocanel/5fd718aece7958246fc72ae0670f5321 to your computer and use it in GitHub Desktop.
Apply selection to kubernetes
#!/bin/sh
#
# Grabs the selected text and apply it to kubernetes using `kubectl`.
#
# OS: Linux
# Requirements: xsel, notify-send
#
# Bind this to a key of your choice.
# Example (i3):
# bindsym $mod+Shift+a exec ~/scripts/k8s/kube-apply-from-clipboard
set +e
TEMP_FILE=$(mktemp /tmp/kubernetes.XXXXXX)
xsel -p -o -n > $TEMP_FILE
KUBE_OUT=`kubectl apply -f $TEMP_FILE`
if [ $? -eq 0 ]; then
notify-send -u normal -a "kubectl" "Succuess: $KUBE_OUT"
else
notify-send -u critical -a "kubectl" "Failed: $KUBE_OUT"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment