{"id":23016528,"url":"https://github.com/alexdesousa/hab","last_synced_at":"2025-08-14T07:32:32.337Z","repository":{"id":78371614,"uuid":"172214549","full_name":"alexdesousa/hab","owner":"alexdesousa","description":"Oh My ZSH plugin for loading OS environment automatically","archived":false,"fork":false,"pushed_at":"2020-03-19T09:24:01.000Z","size":19,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-02T14:51:36.725Z","etag":null,"topics":["environment-variables","zsh-plugin"],"latest_commit_sha":null,"homepage":null,"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/alexdesousa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["alexdesousa"]}},"created_at":"2019-02-23T12:57:07.000Z","updated_at":"2024-12-01T13:45:56.000Z","dependencies_parsed_at":"2023-05-26T17:45:21.052Z","dependency_job_id":null,"html_url":"https://github.com/alexdesousa/hab","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alexdesousa/hab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdesousa%2Fhab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdesousa%2Fhab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdesousa%2Fhab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdesousa%2Fhab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexdesousa","download_url":"https://codeload.github.com/alexdesousa/hab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexdesousa%2Fhab/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270384259,"owners_count":24574528,"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","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["environment-variables","zsh-plugin"],"created_at":"2024-12-15T11:16:42.563Z","updated_at":"2025-08-14T07:32:32.063Z","avatar_url":"https://github.com/alexdesousa.png","language":"Shell","funding_links":["https://github.com/sponsors/alexdesousa"],"categories":["Plugins","Shell"],"sub_categories":["ZSH on Windows","Zinit (née zplugin)"],"readme":"# Hab\n\n\u003e While on Mars, the crew will be living in an artificial habitat, or _Hab_ for\n\u003e short.\n\n`Hab` is an [Oh My ZSH](https://ohmyz.sh/) plugin that loads/unloads OS\nenviroment variables and functions automatically when:\n\n- Changing directories\n- After editing `.envrc` files.\n- Opening new shells.\n\n## Small example\n\nGiven the following `.envrc` file in the folder `my_project`:\n\n```bash\n# file: /home/user/my_project/.envrc\nexport HOSTNAME=\"https://my.hab\"\n\nfunction clean_build() {\n  rm -rf \"$(pwd)/_build\" 2\u003e /dev/null\n  echo \"All cleaned!\"\n}\n```\n\nThen:\n\n1. Loads it when `cd`ing into `my_project`:\n   ```bash\n   ~ $ cd my_project\n   [SUCCESS]  Loaded hab [/home/user/my_project/.envrc]\n\n   ~/my_project $ echo \"$HOSTNAME\"\n   https://my.hab\n\n   ~/my_project $ clean_build\n   All cleaned!\n   ```\n\n2. Unloads it when `cd`ing out of `my_project`\n\n   ```bash\n   ~/my_project $ cd ..\n   [WARN]  Unloaded variable HOSTNAME\n   [WARN]  Unloaded function clean_build\n   ```\n\n## Hab Autoload\n\nThe environment will be (re)loaded automatically every time:\n\n- We change directory and there's a `.envrc` file available.\n- We edit the `.envrc` while its environment was already loaded.\n- We open a new shell in a directory with an `.envrc` file present.\n\n## Different Habs\n\nThough `Hab` it's going to autoload `.envrc` automatically every time you change\ndirectories, you can manually load special environments e.g:\n\nGiven the folliwing environment files:\n\n```bash\n~/my_project $ ls -a\n.\n..\n.envrc\n.envrc.test\n.envrc.dev\n.envrc.prod\n```\n\nWe could load any of them by using its extension (no extension to use the\ndefault one) e.g:\n\n```bash\n~/my_project $ hab dev\n[WARN]     Unloaded variable HOSTNAME\n[WARN]     Unloaded function clean_build\n[SUCCESS]  Loaded hab [/home/user/my_project/.envrc.dev] (Last modified Wed 04 Mar 2020 03:42:52 PM CET)\n```\n\n## `Hab` sub-commands\n\nThough we could never run a command as everything is done automatically, there\nare some useful sub-commands for handling things manually as well:\n\n- Loading environments:\n\n   ```bash\n   ~/my_project $ hab           # Loads .envrc\n   ~/my_project $ hab dev       # Loads .envrc.dev\n   ~/my_project $ hab load      # Loads .envrc\n   ~/my_project $ hab load dev  # Loads .envrc.dev\n   ```\n\n- Reloading environments:\n\n   ```bash\n   ~/my_project $ hab reload    # Reloads current environment\n   ```\n\n- Unloading environments:\n\n   ```bash\n   ~/my_project $ hab unload    # Unloads current environment\n   ```\n\n- Updating `Hab`:\n\n   ```bash\n   ~ $ hab update\n   ```\n\n\u003e **Note**: `hab` command supports ZSH auto-completions.\n\n## Environment file\n\nThe environment file (defaults to `.envrc`) accepts a zsh subset:\n\n- Hab can only load and unload `export`s and `function`s e.g:\n\n   ```bash\n   export MY_VARIABLE=42\n\n   function hello() {\n      echo \"Hello!\"\n   }\n   ```\n\n- Hab ignores comments and empty lines.\n\nAdditionally, if the comment `# INHERIT: true` is found in the file, every\nsub-directory will inherit the environment file (unless there's a file that\noverrides it) e.g. the following file will affect any folder inside\n`~/my_project`:\n\n```bash\n# file: ~/my_project/.envrc\n\n# INHERIT: true\nexport MY_VARIABLE=42\n```\n\n\u003e **Important**: In order for inheritance to work, you need to load the root\n\u003e environment first. If you `cd` directly into a sub-folder without loading the\n\u003e root folder's environment, it won't load the environment.\n\nThe default environment file name can be customized globally by changing the\nvalue of the variable `$HAB_BASE` in your `.zshrc` file e.g:\n\n```bash\nexport HAB_BASE=\".env\"\n```\n\n## Installation\n\nJust clone `Hab` as follows:\n\n```bash\n~ $ git clone \"https://github.com/alexdesousa/hab.git\" \"$ZSH_CUSTOM/plugins/hab\"\n```\n\nAnd add the hab to your `plugins` in `$HOME/.zshrc` file:\n\n```bash\nautoload -U +X compinit \u0026\u0026 compinit\nautoload -U +X bashcompinit \u0026\u0026 bashcompinit\nautoload -U add-zsh-hook\n\nplugins=(\n  hab\n)\n```\n\n\u003e **Note**: The `autoload`s are necessary for auto-completions and hook\n\u003e installation.\n\n## Author\n\nAlexander de Sousa.\n\n## License\n\n`Hab` is released under the MIT License. See the LICENSE file for further\ndetails.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdesousa%2Fhab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexdesousa%2Fhab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexdesousa%2Fhab/lists"}