Created
June 4, 2018 13:12
-
-
Save gonzalesraul/92c45cb473aa61c0399dfa015f903e4c to your computer and use it in GitHub Desktop.
Change default behavior for minikube CLI on `profile` command
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
function minikube() { | |
if [[ $1 == "profile" ]]; then | |
case $2 in | |
list ) | |
current=`grep -oP '(?<="profile": ")[^"]*' $HOME/.minikube/config/config.json` | |
profiles=`ls -1 $HOME/.minikube/profiles` | |
echo -n "* $current" | |
if [[ '' == `echo $profiles|grep $current` ]]; then | |
echo -n " (not created)" | |
fi | |
echo ""; echo ${profiles/$current} |xargs -n 1 echo " " | |
;; | |
set ) | |
command minikube profile "${@:3:4}" | |
;; | |
* ) echo -e "This is used to run and manage multiple minikube instance.\nYou can return to the default minikube profile by running \`minikube profile set default\`\n\nUsage:\n minikube profile [command]\n\nAvailable Commands:\n set\t\tSets the current minikube profile\n list\t\tLists the profiles available\n\n$(minikube help profile |tail -12)" | |
;; | |
esac | |
else | |
command minikube "$@" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OSX doesn't have the
-P
flag for grep anymore, just a heads up