Package: workenv
A shortcut for jumping between local work environments in bash and carrying out tasks
within them.Requires Python 3.7+ and bash.Quick exampleExample~/.workenv_config.yml:myproject:
  path: /path/to/myproject
  source: venv/bin/activate
  run:
  - nvm use
  commands:
    database:
      run: docker-compose up databaseExample usage:# Jump to /path/to/myproject with the local python virtual environment and nvm
we myproject

# Jump to /path/to/myproject and run the database container
we myproject database

# Bash completion support
we m<tab> d<tab>There is also support for a_commonproject with values applied to all projects -
see docs below.InstallationRecommended: Install usingpipx:pipx install workenv
workenv --installAlternative: Install to a virtual environment with:cd path/to/installation
virtualenv --python=python3.8 venv
. venv/bin/activate
pip install workenv
workenv --installBoth of these options will add the command asweby adding a line to your.bashrc.If you would prefer a different command name, you can specify it when installing:workenv --install workonRestart your shell session for your change to take effect.To uninstall, remove the line from.bashrcand uninstall with pipx or delete your virtual environment.ConfigurationAdd the current path as a new project:we --add projectnameAdd the current path as a new command:we --add projectname commandOpen your.workenv_config.ymlfor customisation:we --editConfiguration file formatThe top level of the YAML file are the names of the projects.A project can have the following attributes:pathThe path to set as the current working directory. This will be the first command run.Example:path: /path/to/fooBash equivalent:cd /path/to/foosourcePath or paths to call usingsourceExample:source:
- venv/bin/activate
- .envBash equivalent:source venv/bin/activate
source .envenvDict of environment variables to setExample:env:
  COMPOSE_PROJECT_NAME: my_projectBash equivalent:export COMPOSE_PROJECT_NAME=my_projectrunCommand or list of commands to runExample:run:
- nvm use
- yvm useBash equivalent:nvm use
yvm usecommandsDict of Command objectsExample:myproject:
  commands:
    database:
      run: docker-compose up databaseUsage:we myproject databaseBash equivalent:docker-compose up databaseA command will inherit thepathandenvof its parent project, unless it
defines its own.It will inherit thesourceof its parent project only if it does not specify its
own path or source.A command can have the same attributes as a project, except it cannot define its owncommands.Values can substitute the project name with{{project.name}}or{{project.slug}}.There are two special top-level YAML objects:_configControls settings:verboseIftrue, show bash commands when running themhistoryIftrue, add the commands to history_commonCommon project which can define a commonsource,env,runandcommandswhich will be added to all other projects, regardless of whether they define their
own.The common project cannot specify a path.Full examplePutting together all the options above into a sample.workenv_config.yml:_config:
  verbose: true
  history: false
_common:
  env:
    COMPOSE_PROJECT_NAME: '{{project.slug}}'
  commands:
    open:
      run: xdg-open .
myproject:
  path: /path/to/myproject
  source:
  - venv/bin/activate
  - .env
  run:
  - ./manage.py migrate
  - ./manage.py runserver 0:8000
  commands:
    database:
      run: docker-compose up database
other:
  path: /path/to/otherwe myprojectis equivalent to typing:cd /path/to/myproject
source venv/bin/activate
source .env
export COMPOSE_PROJECT_NAME=myproject
./manage.py migrate
./manage.py runserver 0:8000we myproject databaseis equivalent to typing:cd /path/to/myproject
source venv/bin/activate
source .env
export COMPOSE_PROJECT_NAME=myproject
docker-compose up databasewe otheris equivalent to typing:cd /path/to/other
export COMPOSE_PROJECT_NAME=otherwe other openis equivalent to:cd /path/to/myproject
export COMPOSE_PROJECT_NAME=other
xdg-open .