=======
workenv
=======
A shortcut for jumping between local work environments in bash and carrying out tasks
within them.
Requires Python 3.7+ and bash.
Quick example
=============
Example ``~/.workenv_config.yml``::
myproject:
path: /path/to/myproject
source: venv/bin/activate
run:
- nvm use
commands:
database:
run: docker-compose up database
Example 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 ``_common`` project with values applied to all projects -
see docs below.
Installation
============
**Recommended**: Install using `pipx <https://pypa.github.io/pipx/>`_::
pipx install workenv
workenv --install
**Alternative**: Install to a virtual environment with::
cd path/to/installation
virtualenv --python=python3.8 venv
. venv/bin/activate
pip install workenv
workenv --install
Both of these options will add the command as ``we`` by adding a line to your ``.bashrc``.
If you would prefer a different command name, you can specify it when installing::
workenv --install workon
Restart your shell session for your change to take effect.
To uninstall, remove the line from ``.bashrc`` and uninstall with pipx or delete your virtual environment.
Configuration
=============
Add the current path as a new project::
we --add projectname
Add the current path as a new command::
we --add projectname command
Open your ``.workenv_config.yml`` for customisation::
we --edit
Configuration file format
-------------------------
The top level of the YAML file are the names of the projects.
A project can have the following attributes:
``path``
The path to set as the current working directory. This will be the first command run.
Example::
path: /path/to/foo
Bash equivalent::
cd /path/to/foo
``source``
Path or paths to call using ``source``
Example::
source:
- venv/bin/activate
- .env
Bash equivalent::
source venv/bin/activate
source .env
``env``
Dict of environment variables to set
Example::
env:
COMPOSE_PROJECT_NAME: my_project
Bash equivalent::
export COMPOSE_PROJECT_NAME=my_project
``run``
Command or list of commands to run
Example::
run:
- nvm use
- yvm use
Bash equivalent::
nvm use
yvm use
``commands``
Dict of Command objects
Example::
myproject:
commands:
database:
run: docker-compose up database
Usage::
we myproject database
Bash equivalent::
docker-compose up database
A command will inherit the ``path`` and ``env`` of its parent project, unless it
defines its own.
It will inherit the ``source`` of 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 own
``commands``.
Values can substitute the project name with ``{{project.name}}`` or ``{{project.slug}}``.
There are two special top-level YAML objects:
``_config``
Controls settings:
``verbose``
If ``true``, show bash commands when running them
``history``
If ``true``, add the commands to history
``_common``
Common project which can define a common ``source``, ``env``, ``run`` and ``commands``
which will be added to all other projects, regardless of whether they define their
own.
The common project cannot specify a path.
Full example
============
Putting 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/other
``we myproject`` is 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:8000
``we myproject database`` is equivalent to typing::
cd /path/to/myproject
source venv/bin/activate
source .env
export COMPOSE_PROJECT_NAME=myproject
docker-compose up database
``we other`` is equivalent to typing::
cd /path/to/other
export COMPOSE_PROJECT_NAME=other
``we other open`` is equivalent to::
cd /path/to/myproject
export COMPOSE_PROJECT_NAME=other
xdg-open .
Raw data
{
"_id": null,
"home_page": "https://radiac.net/projects/workenv/",
"name": "workenv",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "bash",
"author": "Richard Terry",
"author_email": "code@radiac.net",
"download_url": "https://files.pythonhosted.org/packages/63/93/a14966f7da17fd53f359d6005330d293507610d3f056924200b0f206ed68/workenv-2.0.1.tar.gz",
"platform": null,
"description": "=======\nworkenv\n=======\n\nA shortcut for jumping between local work environments in bash and carrying out tasks\nwithin them.\n\nRequires Python 3.7+ and bash.\n\n\nQuick example\n=============\n\nExample ``~/.workenv_config.yml``::\n\n myproject:\n path: /path/to/myproject\n source: venv/bin/activate\n run:\n - nvm use\n commands:\n database:\n run: docker-compose up database\n\nExample usage::\n\n # Jump to /path/to/myproject with the local python virtual environment and nvm\n we myproject\n\n # Jump to /path/to/myproject and run the database container\n we myproject database\n\n # Bash completion support\n we m<tab> d<tab>\n\nThere is also support for a ``_common`` project with values applied to all projects -\nsee docs below.\n\n\nInstallation\n============\n\n**Recommended**: Install using `pipx <https://pypa.github.io/pipx/>`_::\n\n pipx install workenv\n workenv --install\n\n**Alternative**: Install to a virtual environment with::\n\n cd path/to/installation\n virtualenv --python=python3.8 venv\n . venv/bin/activate\n pip install workenv\n workenv --install\n\nBoth of these options will add the command as ``we`` by adding a line to your ``.bashrc``.\n\nIf you would prefer a different command name, you can specify it when installing::\n\n workenv --install workon\n\nRestart your shell session for your change to take effect.\n\nTo uninstall, remove the line from ``.bashrc`` and uninstall with pipx or delete your virtual environment.\n\n\nConfiguration\n=============\n\nAdd the current path as a new project::\n\n we --add projectname\n\nAdd the current path as a new command::\n\n we --add projectname command\n\nOpen your ``.workenv_config.yml`` for customisation::\n\n we --edit\n\n\nConfiguration file format\n-------------------------\n\nThe top level of the YAML file are the names of the projects.\n\nA project can have the following attributes:\n\n``path``\n The path to set as the current working directory. This will be the first command run.\n\n Example::\n\n path: /path/to/foo\n\n Bash equivalent::\n\n cd /path/to/foo\n\n\n``source``\n Path or paths to call using ``source``\n\n Example::\n\n source:\n - venv/bin/activate\n - .env\n\n Bash equivalent::\n\n source venv/bin/activate\n source .env\n\n\n``env``\n Dict of environment variables to set\n\n Example::\n\n env:\n COMPOSE_PROJECT_NAME: my_project\n\n Bash equivalent::\n\n export COMPOSE_PROJECT_NAME=my_project\n\n\n``run``\n Command or list of commands to run\n\n Example::\n\n run:\n - nvm use\n - yvm use\n\n Bash equivalent::\n\n nvm use\n yvm use\n\n\n``commands``\n Dict of Command objects\n\n Example::\n\n myproject:\n commands:\n database:\n run: docker-compose up database\n\n Usage::\n\n we myproject database\n\n Bash equivalent::\n\n docker-compose up database\n\n A command will inherit the ``path`` and ``env`` of its parent project, unless it\n defines its own.\n\n It will inherit the ``source`` of its parent project only if it does not specify its\n own path or source.\n\n A command can have the same attributes as a project, except it cannot define its own\n ``commands``.\n\nValues can substitute the project name with ``{{project.name}}`` or ``{{project.slug}}``.\n\nThere are two special top-level YAML objects:\n\n``_config``\n Controls settings:\n\n ``verbose``\n If ``true``, show bash commands when running them\n\n ``history``\n If ``true``, add the commands to history\n\n``_common``\n Common project which can define a common ``source``, ``env``, ``run`` and ``commands``\n which will be added to all other projects, regardless of whether they define their\n own.\n\n The common project cannot specify a path.\n\n\nFull example\n============\n\nPutting together all the options above into a sample ``.workenv_config.yml``::\n\n _config:\n verbose: true\n history: false\n _common:\n env:\n COMPOSE_PROJECT_NAME: '{{project.slug}}'\n commands:\n open:\n run: xdg-open .\n myproject:\n path: /path/to/myproject\n source:\n - venv/bin/activate\n - .env\n run:\n - ./manage.py migrate\n - ./manage.py runserver 0:8000\n commands:\n database:\n run: docker-compose up database\n other:\n path: /path/to/other\n\n\n``we myproject`` is equivalent to typing::\n\n cd /path/to/myproject\n source venv/bin/activate\n source .env\n export COMPOSE_PROJECT_NAME=myproject\n ./manage.py migrate\n ./manage.py runserver 0:8000\n\n``we myproject database`` is equivalent to typing::\n\n cd /path/to/myproject\n source venv/bin/activate\n source .env\n export COMPOSE_PROJECT_NAME=myproject\n docker-compose up database\n\n``we other`` is equivalent to typing::\n\n cd /path/to/other\n export COMPOSE_PROJECT_NAME=other\n\n``we other open`` is equivalent to::\n\n cd /path/to/myproject\n export COMPOSE_PROJECT_NAME=other\n xdg-open .\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "Manage local work environments",
"version": "2.0.1",
"split_keywords": [
"bash"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "91c94837c9274f76602b6e57e3a3b21246682be3b3b81921dfcbc34eb0e03db5",
"md5": "888035962cf139e10bf9426861f4261b",
"sha256": "bd238cac9e756b466f4f8ae2e6580a92be13572f057737e9c305fe53334a1ae8"
},
"downloads": -1,
"filename": "workenv-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "888035962cf139e10bf9426861f4261b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 11276,
"upload_time": "2023-01-08T19:07:08",
"upload_time_iso_8601": "2023-01-08T19:07:08.245751Z",
"url": "https://files.pythonhosted.org/packages/91/c9/4837c9274f76602b6e57e3a3b21246682be3b3b81921dfcbc34eb0e03db5/workenv-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6393a14966f7da17fd53f359d6005330d293507610d3f056924200b0f206ed68",
"md5": "5e6cf4ac9db3d95acf744b08e0fd9f81",
"sha256": "10971f3437a127f3f21eef26a8e54ef31f550c3ff3d88d1cd6a5faf84fecbe27"
},
"downloads": -1,
"filename": "workenv-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "5e6cf4ac9db3d95acf744b08e0fd9f81",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 14473,
"upload_time": "2023-01-08T19:07:09",
"upload_time_iso_8601": "2023-01-08T19:07:09.600028Z",
"url": "https://files.pythonhosted.org/packages/63/93/a14966f7da17fd53f359d6005330d293507610d3f056924200b0f206ed68/workenv-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-08 19:07:09",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "workenv"
}