{"id":13393076,"url":"https://github.com/direnv/direnv","last_synced_at":"2025-05-12T18:29:36.221Z","repository":{"id":1279843,"uuid":"1219305","full_name":"direnv/direnv","owner":"direnv","description":"unclutter your .profile","archived":false,"fork":false,"pushed_at":"2025-04-28T09:53:43.000Z","size":2979,"stargazers_count":13447,"open_issues_count":368,"forks_count":673,"subscribers_count":82,"default_branch":"master","last_synced_at":"2025-05-05T15:55:53.625Z","etag":null,"topics":["bash","buildbot-numtide","direnv","environment","fish","shell","shell-extension","tcsh","zsh"],"latest_commit_sha":null,"homepage":"http://direnv.net","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/direnv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-01-04T12:46:15.000Z","updated_at":"2025-05-05T14:41:40.000Z","dependencies_parsed_at":"2023-07-05T18:17:57.300Z","dependency_job_id":"83f032ce-fb18-450d-b1d3-b4eb7f191685","html_url":"https://github.com/direnv/direnv","commit_stats":{"total_commits":1055,"total_committers":229,"mean_commits":4.606986899563319,"dds":0.6274881516587678,"last_synced_commit":"978008aa7c66e5beb3e3c4a7705c3d0ce4f99f1c"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/direnv%2Fdirenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/direnv%2Fdirenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/direnv%2Fdirenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/direnv%2Fdirenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/direnv","download_url":"https://codeload.github.com/direnv/direnv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253797617,"owners_count":21965933,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","buildbot-numtide","direnv","environment","fish","shell","shell-extension","tcsh","zsh"],"created_at":"2024-07-30T17:00:42.432Z","updated_at":"2025-05-12T18:29:36.173Z","avatar_url":"https://github.com/direnv.png","language":"Go","funding_links":[],"categories":["Go","Uncategorized","Misc","Development","Command-Line Productivity","Shell","Plugins","📝 Prerequisites","zsh","Command Line Tools","補足","bash","终端","Tools","Development Tools","Other","Developer Utilities"],"sub_categories":["Uncategorized","Time Series","environment variable","🔧 Tools","网络服务_其他","Go"],"readme":"direnv -- unclutter your .profile\n=================================\n\n[![Built with Nix](https://builtwithnix.org/badge.svg)](https://builtwithnix.org)\n[![Packaging status](https://repology.org/badge/tiny-repos/direnv.svg)](https://repology.org/project/direnv/versions)\n[![latest packaged version(s)](https://repology.org/badge/latest-versions/direnv.svg)](https://repology.org/project/direnv/versions)\n[![Support room on Matrix](https://img.shields.io/matrix/direnv:numtide.com.svg?label=%23direnv%3Anumtide.com\u0026logo=matrix\u0026server_fqdn=matrix.numtide.com)](https://matrix.to/#/#direnv:numtide.com)\n\n`direnv` is an extension for your shell. It augments existing shells with a\nnew feature that can load and unload environment variables depending on the\ncurrent directory.\n\n## Use cases\n\n* Load [12factor apps](https://12factor.net/) environment variables\n* Create per-project isolated development environments\n* Load secrets for deployment\n\n## How it works\n\nBefore each prompt, direnv checks for the existence of a `.envrc` file (and\n[optionally](man/direnv.toml.1.md#codeloaddotenvcode) a `.env` file) in the current\nand parent directories. If the file exists (and is authorized), it is loaded\ninto a **bash** sub-shell and all exported variables are then captured by\ndirenv and then made available to the current shell.\n\nIt supports hooks for all the common shells like bash, zsh, tcsh and fish.\nThis allows project-specific environment variables without cluttering the\n`~/.profile` file.\n\nBecause direnv is compiled into a single static executable, it is fast enough\nto be unnoticeable on each prompt. It is also language-agnostic and can be\nused to build solutions similar to rbenv, pyenv and phpenv.\n\n## Getting Started\n\n### Prerequisites\n\n* Unix-like operating system (macOS, Linux, ...)\n* A supported shell (bash, zsh, tcsh, fish, elvish, powershell, murex, nushell)\n\n### Basic Installation\n\n1. direnv is packaged in most distributions already. See [the installation documentation](docs/installation.md) for details.\n2. [hook direnv into your shell](docs/hook.md).\n\nNow restart your shell.\n\n### Quick demo\n\nTo follow along in your shell once direnv is installed.\n\n```shell\n# Create a new folder for demo purposes.\n$ mkdir ~/my-project\n$ cd ~/my-project\n\n# Show that the FOO environment variable is not loaded.\n$ echo ${FOO-nope}\nnope\n\n# Create a new .envrc. This file is bash code that is going to be loaded by\n# direnv.\n$ echo export FOO=foo \u003e .envrc\n.envrc is not allowed\n\n# The security mechanism didn't allow to load the .envrc. Since we trust it,\n# let's allow its execution.\n$ direnv allow .\ndirenv: reloading\ndirenv: loading .envrc\ndirenv export: +FOO\n\n# Show that the FOO environment variable is loaded.\n$ echo ${FOO-nope}\nfoo\n\n# Exit the project\n$ cd ..\ndirenv: unloading\n\n# And now FOO is unset again\n$ echo ${FOO-nope}\nnope\n```\n\n### The stdlib\n\nExporting variables by hand is a bit repetitive so direnv provides a set of\nutility functions that are made available in the context of the `.envrc` file.\n\nAs an example, the `PATH_add` function is used to expand and prepend a path to\nthe $PATH environment variable. Instead of `export PATH=$PWD/bin:$PATH` you\ncan write `PATH_add bin`. It's shorter and avoids a common mistake where\n`$PATH=bin`.\n\nTo find the documentation for all available functions check the\n[direnv-stdlib(1) man page](man/direnv-stdlib.1.md).\n\nIt's also possible to create your own extensions by creating a bash file at\n`~/.config/direnv/direnvrc` or `~/.config/direnv/lib/*.sh`. This file is\nloaded before your `.envrc` and thus allows you to make your own extensions to\ndirenv.\n\nNote that this functionality is not supported in `.env` files. If the\ncoexistence of both is needed, one can use `.envrc` for leveraging stdlib and\nappend `dotenv` at the end of it to instruct direnv to also read the `.env`\nfile next.\n\n## Docs\n\n* [Install direnv](docs/installation.md)\n* [Hook into your shell](docs/hook.md)\n* [Develop for direnv](docs/development.md)\n* [Manage your rubies with direnv and ruby-install](docs/ruby.md)\n* [Community Wiki](https://github.com/direnv/direnv/wiki)\n\nMake sure to take a look at the wiki! It contains all sorts of useful\ninformation such as common recipes, editor integration, tips-and-tricks.\n\n### Man pages\n\n* [direnv(1) man page](man/direnv.1.md)\n* [direnv-fetchurl(1) man page](man/direnv-fetchurl.1.md)\n* [direnv-stdlib(1) man page](man/direnv-stdlib.1.md)\n* [direnv.toml(1) man page](man/direnv.toml.1.md)\n\n### FAQ\n\nBased on GitHub issues interactions, here are the top things that have been\nconfusing for users:\n\n1. direnv has a standard library of functions, a collection of utilities that\n   I found useful to have and accumulated over the years. You can find it\n   here: https://github.com/direnv/direnv/blob/master/stdlib.sh\n\n2. It's possible to override the stdlib with your own set of function by\n   adding a bash file to `~/.config/direnv/direnvrc`. This file is loaded and\n   its content made available to any `.envrc` file.\n\n3. direnv is not loading the `.envrc` into the current shell. It's creating a\n   new bash sub-process to load the stdlib, direnvrc and `.envrc`, and only\n   exports the environment diff back to the original shell. This allows direnv\n   to record the environment changes accurately and also work with all sorts\n   of shells. It also means that aliases and functions are not exportable\n   right now.\n\n## Contributing\n\nBug reports, contributions and forks are welcome. All bugs or other forms of\ndiscussion happen on http://github.com/direnv/direnv/issues .\n\nOr drop by on [Matrix](https://matrix.to/#/#direnv:numtide.com) to\nhave a chat. If you ask a question make sure to stay around as not everyone is\nactive all day.\n\n### Testing\n\nTo run our tests, use these commands: (you may need to install [homebrew](https://brew.sh/))\n\n```\nbrew bundle\nmake test\n```\n\n## Complementary projects\n\nHere is a list of projects you might want to look into if you are using direnv.\n\n* [starship](https://starship.rs/) - A cross-shell prompt.\n* [Projects for Nix integration](https://github.com/direnv/direnv/wiki/Nix) - choose from one of a variety of projects offering improvements over Direnv's built-in `use_nix` implementation.\n\n## Related projects\n\nHere is a list of other projects found in the same design space. Feel free to\nsubmit new ones.\n\n* [Environment Modules](http://modules.sourceforge.net/) - one of the oldest (in a good way) environment-loading systems\n* [autoenv](https://github.com/hyperupcall/autoenv) - older, popular, and lightweight.\n* [zsh-autoenv](https://github.com/Tarrasch/zsh-autoenv) - a feature-rich mixture of autoenv and [smartcd](https://github.com/cxreg/smartcd): enter/leave events, nesting, stashing (Zsh-only).\n* [asdf](https://github.com/asdf-vm/asdf) - a pure bash solution that has a plugin system. The [asdf-direnv](https://github.com/asdf-community/asdf-direnv) plugin allows using asdf managed tools with direnv.\n* [ondir](https://github.com/alecthomas/ondir) - OnDir is a small program to automate tasks specific to certain directories\n* [shadowenv](https://shopify.github.io/shadowenv/) - uses an s-expression format to define environment changes that should be executed\n* [quickenv](https://github.com/untitaker/quickenv) - an alternative loader for `.envrc` files that does not hook into your shell and favors speed over convenience.\n* [mise](https://github.com/jdx/mise) - direnv, make and asdf all in one tool.\n\n## Commercial support\n\nLooking for help or customization?\n\nGet in touch with Numtide to get a quote. We make it easy for companies to\nwork with Open Source projects: \u003chttps://numtide.com/contact\u003e\n\n## COPYRIGHT\n\n[MIT licence](LICENSE) - Copyright (C) 2019 @zimbatm and [contributors](https://github.com/direnv/direnv/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirenv%2Fdirenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdirenv%2Fdirenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdirenv%2Fdirenv/lists"}