Last active
August 14, 2020 20:54
-
-
Save cyberbit/addcd7fa2500977ac5b4248ebe124898 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
# Launch a bash session in your docker workspace, from a specified starting directory. | |
# | |
# Usage: larabash [workdir] | |
# workdir: path to starting root directory (defaults to name of current directory) | |
###################################################################################### | |
# Parent directory of project on host machine | |
# for example, project is at /path/to/project/parent/project | |
HOSTROOT="/path/to/project/parent" | |
# Parent directory of project volume in container | |
# for example, project mounts to /var/www/project | |
CONTAINERROOT="/var/www" | |
# the magic :O | |
HOSTPWD=${PWD/$HOSTROOT\//} | |
WORKDIR=${1:-${HOSTPWD}} | |
# Replace with your host root project path | |
cd $HOSTROOT/project | |
# Replace with your launch command of choice, important part is --workdir | |
docker-compose exec --workdir="$CONTAINERROOT/$WORKDIR" container-name bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment