mirror of
https://github.com/kennethreitz/kennethreitz.org.git
synced 2026-06-21 14:50:57 +00:00
197352108b
Essays (72 files): - Strip bloated italic footer link-blocks from all 2025-2026 essays - 669 lines of directory-style footers removed Poetry (7 files): - Fix typos: benig, Analouge's, forsee, y et, seperateness - Remove third-person sidenotes from 6 poems Talks (1 file): - Remove third-person sidenote from developer-burnout Themes (10 files): - Add warm closing paragraphs before Related Themes sections - Fix "he built" → "I built" in evolution-of-ideas Software (3 files): - Fix multiline sidenotes in clint.md - Clarify contradictory maintenance status in autoenv.md - Add Infinite State Sample Pack to software index Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
31 lines
2.1 KiB
Markdown
31 lines
2.1 KiB
Markdown
# autoenv
|
|
|
|
You can install `autoenv` using `pip` or `uv`, but you should likely use `direnv` instead. It's a superior project, these days.
|
|
|
|
```bash
|
|
$ uv pip install autoenv
|
|
```
|
|
|
|
## Usage
|
|
|
|
Autoenv allows you to automatically activate a virtual environment when you `cd` into a directory containing a `.env` file. This can be useful for managing project-specific environment variables and dependencies.
|
|
|
|
To use autoenv, create a `.env` file in your project directory with the necessary environment variables. For example:
|
|
|
|
```bash
|
|
# .env
|
|
export API=blah-blah
|
|
export SECRET_KEY=super-secret
|
|
```
|
|
|
|
When you `cd` into the project directory, autoenv will automatically activate the environment and set the environment variables defined in the `.env` file. The project accomplishes this by hooking into the shell's `cd` command<label for="sn-shell-hook" class="margin-toggle sidenote-number"></label><input type="checkbox" id="sn-shell-hook" class="margin-toggle"/><span class="sidenote">This approach requires modifying shell initialization files like `.bashrc` or `.zshrc` to add the autoenv hook, which intercepts directory changes and checks for `.env` files.</span> and sourcing the `.env` file when you enter the directory.
|
|
|
|
## Conclusion & Alternatives
|
|
|
|
Autoenv was a popular project for managing project-specific environments. Kenneth no longer maintains it, but [Edwin Kofler](https://github.com/hyperupcall) has taken over maintenance of the project. A better alternative for new projects is `direnv`, which provides similar functionality with more features and better performance. It is recommended to use `direnv` instead of `autoenv` for managing project environments.
|
|
|
|
The repository for `autoenv` is available on GitHub<label for="sn-maintenance-transfer" class="margin-toggle sidenote-number"></label><input type="checkbox" id="sn-maintenance-transfer" class="margin-toggle"/><span class="sidenote">Edwin Kofler took over maintenance of the project from Kenneth, ensuring continued support for existing users while the community gradually migrates to more modern alternatives like direnv.</span>.
|
|
|
|
- https://github.com/hyperupcall/autoenv
|
|
- https://direnv.net/docs/hook.html
|