Skip to content

Instantly share code, notes, and snippets.

@benfalk
Created June 15, 2016 19:05
Show Gist options
  • Save benfalk/3a374561156681c1d21fe5d98bef1747 to your computer and use it in GitHub Desktop.
Save benfalk/3a374561156681c1d21fe5d98bef1747 to your computer and use it in GitHub Desktop.
#!/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