Last active
March 25, 2020 20:26
-
-
Save iocanel/5fd718aece7958246fc72ae0670f5321 to your computer and use it in GitHub Desktop.
Apply selection to kubernetes
This file contains hidden or 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
#!/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