. /etc/bash.bashrc # https://askubuntu.com/a/22043 alias sudo='sudo ' # lol alias nano='vim' function git { if [[ "$1" == "clone" && "$@" != *"--help"* ]]; then shift 1 command git clone --config core.filemode=false "$@" elif [[ "$1" == "branch" && "$@" != *"--help"* ]]; then shift 1 command git checkout -b "$@" else command git "$@" fi } function docker { if [[ "$1" == "stop-and-rm" ]]; then shift 1 command docker stop "$@" command docker rm "$@" else command docker "$@" fi } # aliases let you put things after the command if you want # i.e. get familiar with the flags but type way fewer characters # e.g. dc build --no-cache -> rebuild the images without cache # e.g. dcu -d -> dc up and detach/background it # e.g. dce app bash -> dc exec bash in the service # e.g. dcd -v -> dc down and clear volumes too alias dc=docker-compose alias dcd="docker-compose down" alias dcu="docker-compose up" alias dce="docker-compose exec" # persisting the changes you've made to your container # is a terrible idea and yet here it is function dcc { if [ "$#" -ne "1" ]; then echo "Precisely one argument required" return 1 fi CONTAINER=$(dc images | grep "_$1 " | awk '{print $1;}') TAGNAME=$(dc images | grep "_app " | awk '{print $2;}') TAGVERSION=$(dc images | grep "_app " | awk '{print $3;}') if [ "$CONTAINER" = "" ] || [ "$TAGNAME" = "" ] || [ "$TAGVERSION" = "" ]; then echo "Unable to figure out what to do" return 1 fi COMMAND="docker commit $CONTAINER $TAGNAME:$TAGVERSION" echo $COMMAND eval $COMMAND }