Created
June 15, 2016 19:05
-
-
Save benfalk/3a374561156681c1d21fe5d98bef1747 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
#!/usr/bin/env bash | |
if (( $# == 0 )) | |
then | |
exit 0 | |
fi | |
if (( $# == 1 )) | |
then | |
arr=($(echo "$1")) | |
if (( ${#arr[@]} != 2 )) | |
then | |
exit 0 | |
fi | |
config=${arr[0]} | |
term=${arr[1]} | |
fi | |
if (( $# == 2 )) | |
then | |
config=$1 | |
term=$2 | |
fi | |
options=$( | |
kubectl --kubeconfig="$HOME/.kube/$config" get pods | \ | |
grep '^[^ ]*' -o | \ | |
tail -n +2 | \ | |
grep $term | |
) | |
while read -r option; do | |
echo "[$option]" | |
echo "command=copy" | |
echo "icon=" | |
echo "subtext=Copy $option" | |
done <<< "$options" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment