···24242525## d-c
2626Basic wrapper around the `docker-compose` command (which you should have if you got Docker installed). The command works the same as `docker-compose`, except:
2727-- When running `d-c run`, it automatically adds the `--rm` argument
2828-- When running `d-c up`, it automatically runs `docker-compose down` afterwards.
2727+- When running `d-c run`, the `--rm` argument is added (as long as `-d` or `--detach` are not present).
2828+- When running `d-c up`, `d-c down` runs afterwards (as long as `-d` or `--detach` are not present).
29293030If you've installed auto completion for `docker-compose` ([here's how to do that](https://docs.docker.com/compose/completion/)), you can enable auto completion for `d-c` by adding `complete -F _docker_compose d-c` to your `.bash-profile`.
3131
+13-2
bin/d-c
···11#! /bin/bash
2233-if [[ $1 == "run" ]]; then
33+# check for -d, --detached
44+DETACHED=false
55+for (( i=1; i <= "$#"; i++ )); do
66+ ARG="${!i}"
77+ case "$ARG" in
88+ -d|--detach)
99+ DETACHED=true
1010+ ;;
1111+ esac
1212+done
1313+1414+if [[ $1 == "run" ]] && [[ $DETACHED == false ]]; then
415 docker-compose run --rm "${@:2}"
55-elif [[ $1 == "up" ]]; then
1616+elif [[ $1 == "up" ]] && [[ $DETACHED == false ]]; then
617 docker-compose up "${@:2}"; docker-compose down
718else
819 docker-compose "${@:1}"