{"id":13597575,"url":"https://github.com/insomnimus/ps-dotenv","last_synced_at":"2025-03-04T10:05:23.695Z","repository":{"id":45196059,"uuid":"437138188","full_name":"insomnimus/ps-dotenv","owner":"insomnimus","description":"A feature complete and unintrusive direnv for Powershell Core","archived":false,"fork":false,"pushed_at":"2024-08-31T19:03:45.000Z","size":211,"stargazers_count":68,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-25T09:13:22.241Z","etag":null,"topics":["csharp","direnv","dotenv","dotnet","module","powershell"],"latest_commit_sha":null,"homepage":"","language":"C#","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/insomnimus.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":"2021-12-10T23:12:23.000Z","updated_at":"2025-02-17T09:23:01.000Z","dependencies_parsed_at":"2024-09-24T05:01:00.225Z","dependency_job_id":"6b820d7a-6f5e-4115-ab08-a6013c655c3b","html_url":"https://github.com/insomnimus/ps-dotenv","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":0.4117647058823529,"last_synced_commit":"06d3fba1b0d556c18b6171fa58761131634300e1"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnimus%2Fps-dotenv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnimus%2Fps-dotenv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnimus%2Fps-dotenv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insomnimus%2Fps-dotenv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insomnimus","download_url":"https://codeload.github.com/insomnimus/ps-dotenv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241827109,"owners_count":20026601,"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":["csharp","direnv","dotenv","dotnet","module","powershell"],"created_at":"2024-08-01T17:00:36.474Z","updated_at":"2025-03-04T10:05:23.669Z","avatar_url":"https://github.com/insomnimus.png","language":"C#","funding_links":[],"categories":["C# #","Commandline Productivity"],"sub_categories":[],"readme":"[direnv]: https://direnv.net/\n\n# PS-Dotenv\n`Dotenv` is a feature complete and straightforward [direnv][] alternative for Powershell Core.\n\nIt also exposes the parser as a separate project you can use in other code.\n\n## Stability\nDotenv is stable and feature complete. the project is currently in maintain-only state. That means unless there's significant demand for a feature, only bug-fixes and other improvements will be added.\n\n## Features\n- Complete syntax support including multiline strings and string interpolation.\n-\tWorks on any platform where Powershell Core runs.\n-\tLogging with configurable log levels.\n-\tOption to turn the module on and off on the fly.\n-\tOption to add/remove custom filenames for auto sourcing of env files.\n-\tA subset of bash-like parameter expansion: `$val`, `${val}`, `${val?error}`, `${val+replacement}` and `${val-default}`.\n- Opt-in safe mode where files have to be explicitly allowd.\n-\tSmart loading and unloading env variables: you won't lose the previously set values upon unloading, the \"replaced\" values are remembered and kindly reset to their original values.\n-\tIt just works the way you'd expect it to.\n\n## Use Case\nThis module aims to provide the same functionality as [direnv][].\n\nAdd `Update-Dotenv` in your `Prompt` function and as you navigate directories, Dotenv will source the appropriate env files in the current directory and its parents.\n\n## Performance\nProbing for and loading of `.env` files is I/O bound. The parsing itself takes very little time (less than a millisecond on my znver3 cpu).\n\n# Installation\nYou have 3 options:\n\n## (Windows) Via Scoop (recommended)\nFirst add [my bucket](https://github.com/insomnimus/scoop-bucket) to scoop:\n\n`scoop bucket add insomnia https://github.com/insomnimus/scoop-bucket`\n\nInstall the module:\n\n`scoop install ps-dotenv`\n\n## Download a Release Archive\nSimply download the latest release from [the releases page](https://github.com/insomnimus/ps-dotenv/releases).\n\nDownload `Dotenv.zip`, extract and put the `Dotenv` directory under your `$PSModulePath` as with any other module.\n\n## Build From Source\nMake sure you have all the requirements installed:\n\n-\t`git`: To clone the repository.\n-\t`dotnet cli` with .NET SDK 8.0 or above: To build the project.\n-\t`Powershell` version 6.0 or above: To run the build script.\n\nTo build the project, run the commands below.\n\n```powershell\ngit clone https://github.com/insomnimus/ps-dotenv\ncd ps-dotenv\ngit checkout main # This is sometimes  necessary\n./build.ps1 -release\n# Now import the module.\nImport-Module ./bin/Dotenv\n```\n\n# Usage\nFor the env files to be automatically sourced, you'll need to configure your prompt to let `Dotenv` know you possibly changed directories.\n\nYou don't need to check if the current directory changed or if there are files that must be loaded since `Dotenv` takes care of that for you by keeping its own state.\nIf you don't have a powershell profile setup yet, please read [this article from Microsoft](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.2) first.\n\n\u003e Important: Dotenv is disabled by default. You need to enable it with `Enable-Dotenv` in your powershell profile.\n\nFirst, add this in your profile (don't forget to replace `C:\\example\\dotenv` with the actual path to the folder you built in above steps, or if Dotenv is in your module directory, replace the path with `Dotenv`):\n\n```powershell\nImport-Module C:\\example\\dotenv\nEnable-Dotenv # this is important, by default the module is disabled\n```\n\nDepending on if you have a custom prompt follow one of the following steps:\n\n### If you already have a customized prompt\nYou just have to add the following snippet inside your prompt function:\n\n```powershell\n# We check if the command exists to not cause errors.\nif(Test-Path function:/Update-Dotenv) { Dotenv\\Update-Dotenv }\n```\n\n### If you haven't customized your prompt\nIn your powershell profile, define a new prompt (the snippet below is the built-in prompt with dotenv enabled):\n\n```powershell\nfunction prompt {\n\t# Print the built-in prompt:\n\t$(if (Test-Path variable:/PSDebugContext) { '[DBG]: ' }\n\t\telse { '' }) + 'PS ' + $(Get-Location) +\n\t$(if ($NestedPromptLevel -ge 1) { '\u003e\u003e' }) + '\u003e '\n\n\t# We check if the command exists to not cause any errors.\n\tif(Test-Path function:/Update-Dotenv) { Dotenv\\Update-Dotenv }\n}\n```\n\n## Documentation\n\n-\t[All in one page](documentation.md)\n-\t[Individual command docs](docs/)\n-\t[Syntax](syntax.md)\n\n## Commands Overview\n- `Read-Dotenv`: Parses an env file. \n- `Disable-Dotenv`: Disables the module without removing it from the session. \n- `Enable-Dotenv`: Enables the module back. \n- `Update-Dotenv`: Triggers the module to check for env files in the current and parent directories. \n- `Approve-DotenvDir`: Whitelists a directory for dotenv. \n- `Approve-DotenvFile`: Whitelists a particular env file for dotenv. \n- `Deny-DotenvFile`: Unauthorizes an env file. \n- `Register-DotenvName`: Adds a new name to the list of env file names this module will check for. \n- `Unregister-DotenvName`: Removes a name from the list of names this module will consider as an env file. \n- `Add-DotenvPattern`: Adds a glob pattern to the whitelist. \n- `Remove-DotenvPattern`: Removes a pattern from the dotenv whitelist. \n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsomnimus%2Fps-dotenv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsomnimus%2Fps-dotenv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsomnimus%2Fps-dotenv/lists"}