{"id":28198026,"url":"https://github.com/synoet/cdwe","last_synced_at":"2025-05-16T17:17:26.640Z","repository":{"id":181686411,"uuid":"667146355","full_name":"synoet/cdwe","owner":"synoet","description":"⚡️(cd with env) Is a configurable cd wrapper that lets you define your environment per directory.","archived":false,"fork":false,"pushed_at":"2024-06-15T15:24:57.000Z","size":21053,"stargazers_count":41,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-12T20:08:57.662Z","etag":null,"topics":["bash","cd","cli","config","filesystem","fish","linux","rust","zsh"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/cdwe","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/synoet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-07-16T19:41:30.000Z","updated_at":"2025-03-03T02:30:59.000Z","dependencies_parsed_at":"2024-01-12T10:26:56.584Z","dependency_job_id":"9fe6ec4a-52b3-4a74-b59f-14b39fa3c61a","html_url":"https://github.com/synoet/cdwe","commit_stats":{"total_commits":59,"total_committers":2,"mean_commits":29.5,"dds":"0.016949152542372836","last_synced_commit":"07cc4fc9862d53b3d7963357cbe024d9e4781fcb"},"previous_names":["synoet/cdwe"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synoet%2Fcdwe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synoet%2Fcdwe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synoet%2Fcdwe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/synoet%2Fcdwe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/synoet","download_url":"https://codeload.github.com/synoet/cdwe/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254097017,"owners_count":22014137,"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","cli","config","filesystem","fish","linux","rust","zsh"],"created_at":"2025-05-16T17:17:20.787Z","updated_at":"2025-05-16T17:17:26.610Z","avatar_url":"https://github.com/synoet.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n\n# ⚡️cdwe (cd with env)\nA simple configurable cd wrapper that provides powerful utilities for customizing your envionment per directory. \\\n*(For **ZSH** / **BASH** / **FISH** Shells)*\n\n\n[Installation](#installation) •\n[Usage](#usage) •\n[Configuration](#configuration) •\n[Uninstalling](#uninstalling)\n\u003c/div\u003e\n\n![usage](./assets/usage.gif)\n\n## Features\n\n- **Per Directory Environment Variables**\n- **Auto Load .env files in Directories**\n- **Auto Execute Commands in Directories**\n- **Per Directory Aliases**\n- **Works with any CD like Command**\n\n## Installation\n\n1. **Install binary**\n```bash\ncargo install cdwe\n```\n\n2. **Init your shell**\n```bash\ncdwe init zsh # zsh shells\ncdwe init bash # bash shells\ncdwe init fish # fish shells\n```\n\n3. **Reload your shell and start using!**\n```bash\n# check that env var gets set\ncdwe /Users/synoet/dev/projecta\necho $IS_DEBUG\n\n# check that env var gets unset\ncdwe ..\necho $IS_DEBUG\n```\n\n## Usage\n\n### Defining Per Directory Env Variables\n---\n\nYou can explicitly define environment variables in two ways:\n```toml\n[[directory]]\npath = \"/Users/synoet/dev/project\"\nvars = {\"IS_DEBUG\" = \"true\", \"IS_PROD\" = \"false\"}\n\n# or\n\n[[directory]]\npath = \"/Users/synoet/dev/project\"\nvars = [\n    {name=\"IS_DEBUG\", value =\"true\"},\n    {name=\"IS_PROD\", value=\"false\"}\n]\n```\n`path`: the path to your directory you are configuring\n\n`vars`: a map of env vars to set\n\n*By default env vars will also be loaded in subdirectories, in this example `/Users/synoet/dev/project/src` would also have `IS_DEBUG` and `IS_PROD` set*\n\n*OR*\n\n\n```toml\n[[env_variable]]\nname = \"IS_DEBUG\"\nvalue = \"true\"\ndirs = [\n  \"/Users/synoet/dev/project1\",\n  \"/Users/synoet/dev/project2\"\n]\n```\nHere you can define one env var for multiple directories.\n\n`name`: Is the key of the env variable\n\n`value`: is the value of the env variable\n\n`dirs`: Is a list of directories to load this env var for\n\n### Loading From .env files\n---\nThe directory object also takes a `load_from` field\n```toml\n[[directory]]\npath = \"/Users/synoet/dev/project\"\nvars = {\"IS_DEBUG\" = \"true\", \"IS_PROD\" = \"false\"}\nload_from = [\".env\"]\n```\n`load_from`: List of .env file names to auto load in, these should be relative to the dir defined in path.\n\nIn this example we would try to load in a env file at `/Users/synoet/dev/project/.env`\n\n*Unlike per directory env vars, env files are only loaded in the exact matching directory not in subdirectories*\n\n**OR**\n\nSimilarly we can define a single env file for multiple directories\n\n```toml\n[[env_file]]\nload_from = \".env\"\ndirs = [\n  \"/Users/synoet/dev/macro/macro-site/astro\",\n  \"/Users/synoet/dev/macro/app-monorepo/packages/app\"\n]\n```\n\n### Defining Aliases Per Directory\n---\nHere we can define aliases that will be set and unset as functions only in specific directories\n\n```toml\n[[directory]]\npath = \"/Users/synoet/dev/project\"\nvars = {\"IS_DEBUG\" = \"true\", \"IS_PROD\" = \"false\"}\nload_from = [\".env\"]\naliases = [\n    { name = \"build\", commands = [\"yarn cache clean\", \"yarn build\", \"yarn package\"] }\n]\n```\n\nHere we define a `build` alias which will live only in `/User/synoet/dev/project/*` and all subdirectories.\n\n`aliases`: a list of aliases to define for the directory\n\n**OR**\n```toml\n[[alias]]\nname = \"build\"\ncommands = [\"yarn cache clean\", \"yarn build\", \"yarn package\"]\ndirs = [\n    \"/Users/synoet/dev/projecta\",\n    \"/Users/synoet/dev/projectb\"\n]\n```\nHere you are defining the same alias for multiple directories.\n\n### Defining Auto Commands\n---\nHere we can define commands that will automatically run anytime we cd into a specific directory\n```toml\n[[directory]]\npath = \"/Users/synoet/dev/project\"\nvars = {\"IS_DEBUG\" = \"true\", \"IS_PROD\" = \"false\"}\nload_from = [\".env\"]\naliases = [\n    { name = \"build\", commands = [\"yarn cache clean\", \"yarn build\", \"yarn package\"] }\n]\nrun = [\"git fetch -p\", \"ls\"]\n```\nIn this case every time we enter `/Users/synoet/dev/project` cdwe will automatically run `git fetch -p` and `ls`\n\n*Auto Commands also require an exact match and don't propogate to subdirectories*\n\n**OR**\n\n```toml\n[[command]]\nrun = \"git fetch -p\"\ndirs = [\n  \"/Users/synoet/dev/cdwe\",\n  \"/Users/synoet/dev/macro/macro-api\"\n]\n```\n\n## Configuration\n### Global Configuration Options\n```toml\n[config]\n# Shell (Created during cdwe init \u003cshell\u003e)\nshell = \"zsh\"\n# Custom CD Command (defaults to cd)\ncd_command = \"z\"\n# Show alias hints on cd\nalias_hints = true\n# Show env hints on cd\nenv_hints = true\n# shoe run hints on cd\nrun_hints = true\n```\n\n### Example Configuration\n```toml\n[config]\ncd_command = \"z\"\nalias_hints = true\nenv_hints = true\ncommand_hints = true\nrun_hints = true\nshell = \"zsh\"\n\n# Defined a directory\n# Will have env var \"TEST\" set in this directory\n# Will auto run \"git fetch -p\" whenever you cd into this dir\n# Exposes the following aliases in that directory and sub dirs\n[[directory]]\npath = \"/Users/synoet/dev/cdwe\"\nvars = { \"TEST\" = \"testing\" }\nruns = [\"git fetch -p\"]\naliases = [\n  { name = \"build\", commands = [\"cargo build --release\"]},\n  { name = \"run\", commands = [\"cargo run\"]},\n  { name = \"ci\", commands = [\"cargo fmt\", \"cargo test\"]}\n]\n\n# sets the \"ENV_VAR\" env var in the following directories\n[[env_variable]]\nname = \"ENV_VAR\"\nvalue = \"THIS IS A TEST\"\ndirs = [\n  \"/Users/synoet/dev/cdwe\",\n  \"/Users/synoet/dev/ballast\"\n]\n\n# auto loads from .env file in following directories\n[[env_file]]\nload_from = \".env\"\ndirs = [\n  \"/Users/synoet/dev/cdwe\",\n  \"/Users/synoet/dev/project-api\"\n]\n\n# will auto run the command \"git fetch -p\" in the following directories\n[[command]]\nrun = \"git fetch -p\"\ndirs = [\n  \"/Users/synoet/dev/cdwe\",\n  \"/Users/synoet/dev/project-api\"\n]\n```\n\n### Using CDWE Environment Variables in the paths\n\nIf you want to use something like **$HOME** or any other environment variable\nset in a path, you can do so by wrapping the environment variable inside of\n`{{}}`. Using **$HOME** as an example, you would do {{HOME}}. This can make\nusing one cdwe.toml across many machines nice if you have different users but a\nsimilar directory structure for each user.\n\n## Uninstalling\n1. Run cdwe-remove to clean up all shell artifacts\n```bash\ncdwe-remove #removes the `source \u003coutput\u003e` from your .zshrc/.bashrc/.fish\n\nzsh #reload your shell, use bash or fish if you use those.\n```\n\n2. Uninstall binary\n```bash\ncargo uninstall cdwe\n```\n\n","funding_links":[],"categories":["\u003ca name=\"cd\"\u003e\u003c/a\u003eDirectory changers (alternatives to cd)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynoet%2Fcdwe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsynoet%2Fcdwe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsynoet%2Fcdwe/lists"}