{"id":19309664,"url":"https://github.com/roxma/envrc-rs","last_synced_at":"2025-04-22T13:33:26.802Z","repository":{"id":57625476,"uuid":"135422541","full_name":"roxma/envrc-rs","owner":"roxma","description":"Auto source bash .envrc of your workspace","archived":false,"fork":false,"pushed_at":"2024-02-14T05:31:45.000Z","size":23,"stargazers_count":31,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-03-15T14:04:48.548Z","etag":null,"topics":["bash","cd","direnv","environment","shell-extension","terminal"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/roxma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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}},"created_at":"2018-05-30T09:48:36.000Z","updated_at":"2024-03-14T09:23:42.000Z","dependencies_parsed_at":"2024-11-10T00:22:25.159Z","dependency_job_id":"4ae86f84-864c-4d03-9fd6-82cc4be116fe","html_url":"https://github.com/roxma/envrc-rs","commit_stats":{"total_commits":46,"total_committers":1,"mean_commits":46.0,"dds":0.0,"last_synced_commit":"dd72233ad0bcec367c6dbaddbb4a06f845501903"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxma%2Fenvrc-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxma%2Fenvrc-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxma%2Fenvrc-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roxma%2Fenvrc-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roxma","download_url":"https://codeload.github.com/roxma/envrc-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250248987,"owners_count":21399367,"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","cd","direnv","environment","shell-extension","terminal"],"created_at":"2024-11-10T00:20:13.626Z","updated_at":"2025-04-22T13:33:26.568Z","avatar_url":"https://github.com/roxma.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# envrc - Auto source bash .envrc of your workspace\n\n## Wny?\n\nFirstly, [direnv](https://github.com/direnv/direnv) doesn't officially\n[support alias](https://github.com/direnv/direnv/issues/73) at the moment.\n\nSecondly,\n\n\u003e direnv is actually creating a new bash process to load the stdlib, direnvrc\n\u003e and .envrc, and only exports the environment diff back to the original\n\u003e shell.\n\nHowever, envrc is simpler. It spawns a new interactive bash and load `.envrc`.\nWhen you `cd` out of the directory, the shell exits and returns terminal back\nto the original shell.\n\n## Install\n\n- `cargo install envrc`\n- Add `PROMPT_COMMAND='eval \"$(envrc bash)\"'` to the end of your bashrc\n\n## Usage\n\n```\n$ mkdir foo\n$ \n$ echo 'echo in foo directory' \u003e foo/.envrc\n$ \n$ cd foo\n  envrc: spawning new /bin/bash\n  envrc: loading [/home/roxma/test/envrc/foo/.envrc]\n  in foo directory\n$ \n$ cd ..\n  envrc: exit [/home/roxma/test/envrc/foo/.envrc]\n```\n\n```\n$ envrc\n  envrc 0.2\n  Rox Ma roxma@qq.com\n  auto source .envrc of your workspace\n\n  USAGE:\n      envrc [SUBCOMMAND]\n\n  FLAGS:\n      -h, --help       Prints help information\n      -V, --version    Prints version information\n\n  SUBCOMMANDS:\n      allow    Grant permission to envrc to load the .envrc\n      bash     for bashrc: PROMPT_COMMAND='eval \"$(envrc bash)\"'\n      deny     Remove the permission\n      help     Prints this message or the help of the given subcommand(s)\n      prune    Remove expired or non-existing-file permissions\n```\n\nNote: Take care of your background jobs before getting out of `.envrc`.\n\n## .envrc tips\n\n- `export WORKSPACE_DIR=$(readlink -f \"$(dirname \"${BASH_SOURCE[0]}\")\")` for\n  `.envrc` to locate its directory.\n- `exec bash` to reload the modifed `.envrc`\n\n## .bashrc config\n\n```bash\n# If the `.envrc` is allowed, but not sourced for 1d since last unload, It\n# will be considered expired\nexport ENVRC_ALLOW_DURATION=$((60*60*24))\nPROMPT_COMMAND='eval \"$(envrc bash)\"'\n```\n\n## Why not bash/python?\n\nThe first working commit is written in python. But there's noticeable time lag\nwith the python version on my PC. Rewriting it with perl doesn't help either.\nThen I decided to switch to rust.\n\n```\n$ time envrc.py bash-prompt-command \u003e/dev/null\nreal    0m0.079s\nuser    0m0.044s\nsys     0m0.004s\n```\n\nI have also tried a pure bash implementation. It works better than the python\nimplementation, since most of the python overhead is its startup time.  Most\nof the bash overhead is fork/exec of sub-processes and it's way slower than\nthe rust implementation. Read [#1](https://github.com/roxma/envrc-rs/issues/1)\nfor more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froxma%2Fenvrc-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froxma%2Fenvrc-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froxma%2Fenvrc-rs/lists"}