Skip to content

Instantly share code, notes, and snippets.

@gonzalesraul
Created June 4, 2018 13:12
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 gonzalesraul/92c45cb473aa61c0399dfa015f903e4c to your computer and use it in GitHub Desktop.
Save gonzalesraul/92c45cb473aa61c0399dfa015f903e4c to your computer and use it in GitHub Desktop.
Change default behavior for minikube CLI on `profile` command
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
}
@malkir
Copy link

malkir commented Oct 20, 2018

OSX doesn't have the -P flag for grep anymore, just a heads up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment