{"id":22371290,"url":"https://github.com/ins0mniaque/srcenv","last_synced_at":"2026-04-18T17:01:47.756Z","repository":{"id":264184247,"uuid":"892587152","full_name":"ins0mniaque/srcenv","owner":"ins0mniaque","description":"A cross-shell tool for sourcing POSIX compliant .env scripts","archived":false,"fork":false,"pushed_at":"2025-01-02T09:04:41.000Z","size":238,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T16:53:01.680Z","etag":null,"topics":["bash","elvish","env","environment","fish","ion-shell","murex","nu","posix","pwsh","shell","windows","xonsh","zsh"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/ins0mniaque.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-11-22T11:54:32.000Z","updated_at":"2025-01-02T09:04:45.000Z","dependencies_parsed_at":"2024-12-14T12:18:19.310Z","dependency_job_id":"e1668bf6-267d-4cea-843e-0be83a8736b6","html_url":"https://github.com/ins0mniaque/srcenv","commit_stats":null,"previous_names":["ins0mniaque/srcenv"],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/ins0mniaque/srcenv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ins0mniaque%2Fsrcenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ins0mniaque%2Fsrcenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ins0mniaque%2Fsrcenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ins0mniaque%2Fsrcenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ins0mniaque","download_url":"https://codeload.github.com/ins0mniaque/srcenv/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ins0mniaque%2Fsrcenv/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31976805,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T16:27:12.723Z","status":"ssl_error","status_checked_at":"2026-04-18T16:27:11.140Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","elvish","env","environment","fish","ion-shell","murex","nu","posix","pwsh","shell","windows","xonsh","zsh"],"created_at":"2024-12-04T20:18:42.818Z","updated_at":"2026-04-18T17:01:47.697Z","avatar_url":"https://github.com/ins0mniaque.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# srcenv\n\n[![Version](https://img.shields.io/github/v/release/ins0mniaque/srcenv)](https://github.com/ins0mniaque/srcenv/releases)\n[![License](https://img.shields.io/github/license/ins0mniaque/srcenv)](https://github.com/ins0mniaque/srcenv/blob/master/LICENSE)\n[![CI](https://github.com/ins0mniaque/srcenv/actions/workflows/ci.yml/badge.svg)](https://github.com/ins0mniaque/srcenv/actions/workflows/ci.yml)\n[![Release](https://github.com/ins0mniaque/srcenv/actions/workflows/release.yml/badge.svg)](https://github.com/ins0mniaque/srcenv/actions/workflows/release.yml)\n\n[Installation](#installation) / [Usage](#usage) / [Roadmap](#roadmap) / [Contributing](#contributing)\n\nA cross-shell tool for sourcing POSIX compliant .env scripts.\n\n## Description\n\nsrcenv takes a snapshot of the POSIX shell environment, sources the .env scripts\nand prints a shell specific script exporting the environment variables that have\nchanged since the snapshot, with support for reverting those changes.\n\n## Installation\n\n\u003e [!IMPORTANT]\n\u003e [sh](https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sh.html) _(or any POSIX shell)_ is required to evaluate the `.env` scripts. On [Windows](#windows), srcenv can use `sh.exe` installed by [git](https://git-scm.com).\n\u003e\n\u003e [jq](https://jqlang.github.io/jq) _(version ≥ 1.5)_ is required and needs to be in your `PATH`; see [installation options](https://jqlang.github.io/jq/download).\n\n### Homebrew\n\n```bash\nbrew install ins0mniaque/srcenv/srcenv\n```\n\n### Arch / Debian / RPM packages\n\nDownload the latest packages from the [GitHub release page](https://github.com/ins0mniaque/srcenv/releases).\n\n### Windows\n\n\u003cdetails\u003e\n    \u003csummary\u003ePowerShell\u003c/summary\u003e\u003cp\u003e\u003c/p\u003e\n\nInstall for current user:\n\n```powershell\n# Create installation directory\nNew-Item \"$Env:LOCALAPPDATA\\srcenv\" -ItemType Directory\n\n# Download srcenv to installation directory\nInvoke-WebRequest https://raw.githubusercontent.com/ins0mniaque/srcenv/main/srcenv -OutFile \"$Env:LOCALAPPDATA\\srcenv\\srcenv\"\n```\n\nAdd to `$HOME\\Documents\\PowerShell\\Profile.ps1`:\n\n```powershell\n# Add POSIX shell (sh) to PATH\n$Env:PATH += \";$Env:ProgramFiles\\Git\\usr\\bin\\\"\n\n# Initialize srcenv\nInvoke-Expression (sh \"$Env:LOCALAPPDATA\\srcenv\\srcenv\" init pwsh)\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n    \u003csummary\u003eWindows Command shell \u003ci\u003e(cmd)\u003c/i\u003e\u003c/summary\u003e\u003cp\u003e\u003c/p\u003e\n\nInstall for current user:\n\n\u003e Download [srcenv](https://raw.githubusercontent.com/ins0mniaque/srcenv/main/srcenv) to `%LOCALAPPDATA%\\srcenv` directory or use PowerShell script above to install srcenv.\n\nRun or add to `HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Command Processor\\AutoRun` registry key:\n\n```bat\n@echo off\n\nrem Add POSIX shell (sh) to PATH\nset PATH=%PATH%;%PROGRAMFILES%\\Git\\usr\\bin\\\n\nrem Initialize srcenv\nsh \"%LOCALAPPDATA%\\srcenv\\srcenv\" init cmd \u003e %TEMP%\\srcenv.init.cmd \u0026\u0026 call %TEMP%\\srcenv.init.cmd \u0026 del %TEMP%\\srcenv.init.cmd\n\necho on\n```\n\n\u003c/details\u003e\n\n### Manual\n\nDownload the [latest script](https://raw.githubusercontent.com/ins0mniaque/srcenv/main/srcenv) and/or [man page](https://raw.githubusercontent.com/ins0mniaque/srcenv/main/srcenv.1) and make it executable:\n\n```bash\ncurl -OL https://raw.githubusercontent.com/ins0mniaque/srcenv/main/srcenv\ncurl -OL https://raw.githubusercontent.com/ins0mniaque/srcenv/main/srcenv.1\n\nchmod +x srcenv\n```\n\n_or_\n\nClone the repository:\n\n```bash\ngit clone https://github.com/ins0mniaque/srcenv\n```\n\n## Usage\n\nsrcenv can integrate with your shell and add the following command to source `.env` scripts:\n\n```bash\nsrc [options] [files]\n    [-h|--help|--version]\n```\n\n```bash\n❯ src project.env     # Sources `project.env`\nsrcenv: +COMPILER_OPTIONS +PROJECT_PATH\n\n❯ src project2.env    # Reverts `project.env` and sources `project2.env`\nsrcenv: ~COMPILER_OPTIONS -PROJECT_PATH +PROJECT2_PATH\n\n❯ src --restore       # Reverts `project2.env` (same as src -r)\nsrcenv: -COMPILER_OPTIONS -PROJECT2_PATH\n\n❯ src --version       # Shows the version of srcenv\nsrcenv x.y.z\n\n❯ _\n```\n\n### Shell integration\n\nTo add the `src` command, add the following to your shell's configuration file:\n\n| Shell           | Command                                               |\n|-----------------|-------------------------------------------------------|\n| POSIX           | `source \u003c(srcenv init bash)`                          |\n|                 | `source \u003c(srcenv init dash)`                          |\n|                 | `source \u003c(srcenv init ksh)`                           |\n|                 | `source \u003c(srcenv init zsh)`                           |\n| Csh/Tcsh        | `srcenv init csh \\| source /dev/stdin`                |\n|                 | `srcenv init tcsh \\| source /dev/stdin`               |\n| Elvish          | `var src~ = { }; eval \u0026on-end={\\|ns\\| set src~ = $ns[src] } (srcenv init elvish)` |\n| Murex           | `srcenv init murex -\u003e source`                         |\n| Nushell         | `srcenv init nu \\| save -f srcenv.init.nu` _(env.nu)_ |\n|                 | `source srcenv.init.nu` _(config.nu)_                 |\n| Fish            | `srcenv init fish \\| source`                          |\n| ion             | `eval \"$(srcenv init ion)` _(Usage is different; see [ion shell](#ion-shell))_ |\n| PowerShell      | `Invoke-Expression (sh \"/path/to/srcenv\" init pwsh)`  |\n| Xonsh           | `execx($(srcenv init xonsh))`                         |\n| Windows Command | `@echo off \u0026 sh \"/path/to/srcenv\" init cmd \u003e %TEMP%\\srcenv.init.cmd \u0026\u0026 call %TEMP%\\srcenv.init.cmd \u0026 del %TEMP%\\srcenv.init.cmd \u0026 echo on` _(HKCU\\SOFTWARE\\Microsoft\\Command Processor\\AutoRun)_ |\n| Windows Command (Clink) | `os.execute(io.popen('sh /path/to/srcenv init clink'):read('*a'))` _(%LOCALAPPDATA%\\\\clink\\\\srcenv.lua)_ |\n\n\u003e [!NOTE]\n\u003e To use a different command name _(e.g. `magicenv`)_, add `--cmd magicenv`.\n\u003e You can also pass different arguments to srcenv with `--` at the end. Without `--`, the default options are `--backup --restore --verbose`.\n\u003e\n\u003e _e.g. `source \u003c(srcenv init bash --cmd srcundo -- --restore)` creates a command named `srcundo` that restores the last backed up changes._\n\n\u003e [!TIP]\n\u003e To improve performance or compatibility, you can specify different POSIX shell with `--sh`. If available, dash or ksh usually outperform bash and zsh.\n\u003e\n\u003e To further improve performance when using colored output, use `src --export-colors` **once** to cache terminal capabilities in the `SRCENV_COLORS` environment variable.\n\nFor non-standard integration, use `srcenv rc \u003cshell\u003e [--cmd name] [--sh sh] [-- options]` to output what needs to be added to your shell's configuration file.\n\nFor a list of supported options, see `src --help`.\n\n#### ion shell\n\nion shell implements variadic functions using the array syntax `[...]`. `src` arguments must be provided inside brackets.\n\n_e.g. `src [ project.env ]` or `src [ --help ]`_\n\n\u003e [!WARNING]\n\u003e ion shell has no way to unset environment variables; they are instead set to an empty string.\n\n### Direct usage _(without shell integration)_\n\nThe following table shows how to source `.env` in different shells:\n\n| Shell           | Command                                              |\n|-----------------|------------------------------------------------------|\n| POSIX           | `source \u003c(srcenv sh .env)`                           |\n| Csh/Tcsh        | `srcenv csh .env \\| source /dev/stdin`               |\n| Elvish          | `eval (srcenv elvish .env \\| slurp)`                 |\n| Murex           | `srcenv murex .env -\u003e source`                        |\n| Nushell         | `srcenv json .env \\| from json \\| load-env`          |\n| Fish            | `srcenv fish .env \\| source`                         |\n| ion             | `eval \"$(srcenv ion .env)`                           |\n| PowerShell      | `Invoke-Expression (sh \"/path/to/srcenv\" pwsh .env)` |\n| Xonsh           | `execx($(srcenv xonsh .env))`                        |\n| Windows Command | `@echo off \u0026 sh \"/path/to/srcenv\" cmd .env \u003e %TEMP%\\srcenv.temp.cmd \u0026\u0026 call %TEMP%\\srcenv.temp.cmd \u0026 del %TEMP%\\srcenv.temp.cmd \u0026 echo on` |\n\nFor a list of supported shells and options, see `srcenv --help`.\n\nFor more advanced usage see the [srcenv(1) manpage](https://github.com/ins0mniaque/srcenv/blob/main/srcenv.1.md) (`man ./srcenv.1`).\n\n## Roadmap\n\n- [x] ~~Add [Clink](https://chrisant996.github.io/clink/clink.html) support~~\n- [x] ~~Add [ion](https://gitlab.redox-os.org/redox-os/ion) support~~\n- [x] ~~Add [Xonsh](https://xon.sh) support~~\n- [ ] Automatic mode _(à la [direnv](https://direnv.net))_\n\n## Contributing\n\nSee [CONTRIBUTING.md](https://github.com/ins0mniaque/srcenv/blob/main/CONTRIBUTING.md) for more information on how to contribute.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fins0mniaque%2Fsrcenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fins0mniaque%2Fsrcenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fins0mniaque%2Fsrcenv/lists"}