Skip to content

Instantly share code, notes, and snippets.

@antonkomarev
Last active March 8, 2022 20:48
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 antonkomarev/bd0b980473929f26bb66e8295a60739f to your computer and use it in GitHub Desktop.
Save antonkomarev/bd0b980473929f26bb66e8295a60739f to your computer and use it in GitHub Desktop.
Restart docker on MacOS, quick git commands
# vi ~/.bash_profile
# Docker
d () {
if [ -f $1 ] ; then
echo "Available commands:"
echo " \e[32md restart\e[0m - Restart docker service"
echo " \e[32md stop\e[0m - Stop all docker containers"
return 0
fi
if [ $1 = "restart" ]; then
echo "Killing docker processes"
test -z "$(killall docker 2>/dev/null)"
echo "Quitting Docker app"
osascript -e 'quit app "Docker"'
echo "Launching Docker app"
open --background -a Docker
return 0
elif [ $1 = "stop" ]; then
echo "Stopping all docker containers"
docker ps -q | xargs -L1 docker stop
else
echo "Unknown argument: $1"
return 1
fi
}
# Git
g () {
if [ -f $1 ] ; then
echo "Available commands:"
echo " \e[32mg push-all\e[0m - Push all files"
return 0
fi
if [ $1 = "push-all" ]; then
git add . && git commit -m "WIP" && git push
fi
}
# vi ~/.zshrc
if [ -f ~/.bash_profile ]; then
. ~/.bash_profile
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment