Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mdub/withenv
Execute Shell commands in a specified environment
https://github.com/mdub/withenv
Last synced: about 2 months ago
JSON representation
Execute Shell commands in a specified environment
- Host: GitHub
- URL: https://github.com/mdub/withenv
- Owner: mdub
- License: mit
- Created: 2013-03-23T06:41:29.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-30T03:24:44.000Z (about 9 years ago)
- Last Synced: 2023-04-13T04:02:23.645Z (over 1 year ago)
- Language: Shell
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# withenv
"withenv" runs a shell command in the context of a named environment.
For example:
$ withenv my-aws-credentials -- aws s3 list-buckets
Here, "`my-aws-credentials`" is the name of the environment, and "`aws s3 list-buckets`" is the command to run.
## Installing it
"withenv" is implemented using bash shell functions. Install it with:
source path/to/withenv/withenv.bash
## Defining environments
In this context, an "environment" means a set of environment variables. You define environments by creating shell-script fragments which set environment variables, e.g.
# /Users/mdub/.withenv/my-aws-credentials
export AWS_ACCESS_KEY_ID=AKIBIJQ4XSWNFIF426NQ
export AWS_SECRET_ACCESS_KEY=abNFIEVdwcQdeadbeefnnShq4B1pG7qZ9sqNwoFOThey're just shell scripts; `withenv` will "`source`" them as required.
## Using it
You can specify a full path to the environment file:
$ withenv /etc/aws-credentials.sh -- aws ec2 list-instances
Or, you can just supply a short-name (as in the first example), in which case we'll look for the file in `$WITHENV_DIR` (which defaults to `$HOME/.withenv`).
If multiple environments are specifed, `withenv` will load them all:
$ withenv my-aws-credentials ruby-gc -- funky-aws-stuff.rb
## Bash completion
`withenv` comes complete with Bash programmable completion support, for no extra cost. For example:
$ withenv my-aw[TAB]
$ withenv my-aws-credentials