{"id":13961571,"url":"https://github.com/evanthegrayt/cdc","last_synced_at":"2025-07-21T06:31:07.287Z","repository":{"id":51043562,"uuid":"159408072","full_name":"evanthegrayt/cdc","owner":"evanthegrayt","description":"☣️ Shell plugin for zsh/bash that allows you to cd to subdirectories of user-defined directories from anywhere, without editing CDPATH. ","archived":false,"fork":false,"pushed_at":"2025-01-28T14:53:58.000Z","size":103,"stargazers_count":23,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T14:54:38.238Z","etag":null,"topics":["bash","bash-it","cdc","cdpath","directory","function","oh-my-zsh","plugin","productivity","tab-completion","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/evanthegrayt.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-11-27T22:24:42.000Z","updated_at":"2025-01-28T14:54:01.000Z","dependencies_parsed_at":"2024-01-03T04:16:25.699Z","dependency_job_id":"795f2bd7-642b-4a2f-bf69-ceb8b824b835","html_url":"https://github.com/evanthegrayt/cdc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/evanthegrayt/cdc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanthegrayt%2Fcdc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanthegrayt%2Fcdc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanthegrayt%2Fcdc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanthegrayt%2Fcdc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evanthegrayt","download_url":"https://codeload.github.com/evanthegrayt/cdc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanthegrayt%2Fcdc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266253505,"owners_count":23900051,"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","bash-it","cdc","cdpath","directory","function","oh-my-zsh","plugin","productivity","tab-completion","zsh"],"created_at":"2024-08-08T17:01:16.366Z","updated_at":"2025-07-21T06:31:07.273Z","avatar_url":"https://github.com/evanthegrayt.png","language":"Shell","readme":"# $ cdc [dir]\n\u003e If your repositories are spread throughout your system like a pandemic, then\n\u003e `cdc` is the solution!\n\nView on [GitHub](https://github.com/evanthegrayt/cdc) |\n[GitHub Pages](https://evanthegrayt.github.io/cdc/)\n\n# Version Update!\nNote that `cdc` was recently updated with breaking changes. If you're\nexperiencing issues, please check [this section](#telling-cdc-where-to-look) of\nthe docs, and ensure you're declaring your variables correctly.\n\nIn short, the `CDC_DIRS`, `CDC_IGNORE`, and `CDC_REPO_MARKERS` used to be\ndeclared as arrays, but you can't export environmental variables as arrays; they\nmust be a string. So if your variables looked like this:\n\n```sh\nexport CDC_DIRS=(/home/user/one /home/user/two)\nexport CDC_IGNORE=(notes_directory training)\nexport CDC_REPO_MARKERS=(.git/ .git Rakefile Makefile .hg/ .bzr/ .svn/)\n```\n\n...they should now look like this -- a string separated by colons, like `$PATH`:\n\n```sh\nexport CDC_DIRS=/home/user/one:/home/user/two\nexport CDC_IGNORE=notes_directory:training\nexport CDC_REPO_MARKERS=.git/:.git:Rakefile:Makefile:.hg/:.bzr/:.svn/\n```\n\n## About\n### Overview\nI have a few directories in which I clone repositories, so hopping from one\nproject to another can be tedious. This plugin provides a way to change\ndirectory to any repository, regardless of where it's located, with `cdc\n[REPOSITORY]`. The only setup necessary is to specify which paths the plugin\nshould check for the repository. The plugin comes with tab-completion, as long\nas your `zsh`/`bash` version supports it. The plugin also includes session\nhistory, and has options available that behave similar to the `pushd`, `popd`,\nand `dirs` commands.\n\nWhile this plugin was written for directories that contain repositories, you can\nobviously use it for adding any directories to your `cd` path. In fact, this is\nthe default behavior, but you *can* force `cdc` to only recognize repositories\nwith a simple [configuration change](#only-recognize-actual-repositories).\n\n### Rationale\nI chose to make this function rather than editing `$CDPATH` because I don't like\nchanging the default behavior of `cd`, but you could just as easily do the\nfollowing:\n\n```sh\n# Assuming `repository` exists in `/path/to/repo_dir`\nCDPATH=/path/to/repo_dir\n\ncd repository # will cd to /path/to/repo_dir/repository\n```\n\nAlternatively, you could make aliases:\n\n```sh\nalias repository='cd /path/to/repo_dir/repository'\n```\n\nI don't like this method either, as it just pollutes your environment. In my\nopinion, the less aliases, the better. Also, you now have to remember an alias\nfor each repository. `cdc` solves this issue with its tab-completion.\n\n### Why the name \"cdc\"?\nI wanted something fast to type that wasn't already a command or builtin. You\nalready type `cd` a million times a day, and you don't even have to move your\nfinger to hit the \u003ckbd\u003ec\u003c/kbd\u003e key again. You can't get much faster.\n\n## Installation\n### oh-my-zsh\nClone the repository in your `$ZSH_CUSTOM/plugins` directory\n```sh\ngit clone https://github.com/evanthegrayt/cdc.git $ZSH_CUSTOM/plugins/cdc\n```\nThen add the plugin to your `$HOME/.zshrc` file in the `plugins` array:\n```sh\nplugins=(cdc) # Obviously, leave your other plugins in the array.\n```\n\n### bash-it\nClone the repository in your `$BASH_IT_CUSTOM` directory\n```sh\ngit clone https://github.com/evanthegrayt/cdc.git $BASH_IT_CUSTOM/cdc\n```\nFiles in this directory that end with `.bash` are automatically sourced, so\nthere's nothing else to do.\n\n### Vanilla zsh or bash\nClone the repository wherever you like, and source either the `cdc.plugin.zsh`\nfile for `zsh`, or `cdc.plugin.bash` file for `bash`, from one of your startup\nfiles, such as `~/.zshrc` or `~/.bashrc`, respectively.\n\n```sh\n# Where $INSTALLATION_PATH is the path to where you installed the plugin.\nsource $INSTALLATION_PATH/cdc.plugin.zsh  # in ~/.zshrc\nsource $INSTALLATION_PATH/cdc.plugin.bash # in ~/.bashrc\n```\n\nIf you're using a version of `zsh`/`bash` that doesn't support the completion\nfeatures, or you just don't want to use them, just source the `cdc.sh` file\ndirectly.\n\n```sh\nsource $INSTALLATION_PATH/cdc.sh # in either ~/.zshrc or ~/.bashrc\n```\n\n## Set-up\nThe following settings require variables to be set from a startup file, such as\n`~/.zshrc` or `~/.bashrc`.  You can view an example of this in [my config\nfile](https://github.com/evanthegrayt/dotfiles/blob/master/dotfiles/shellrc#L27).\n\n### Telling cdc where to look\nTo use this plugin, you need to `export CDC_DIRS` in a startup file. It should\nbe a string with absolute paths to the directories to search, separated by\ncolons (similar to `$PATH`).\n\n```sh\n# Set this in ~/.zshrc or similar\nexport CDC_DIRS=$HOME/dir_with_repos:$HOME/workspace/another_dir_with_repos\n```\n\nNote that the order of the paths in the string matters. The plugin will `cd`\nto the first match it finds, so if you have the same repository -- or two\nrepositories with the same name -- in two places, the first location in the\nstring will take precedence. There is currently an issue to better handle this\n\"feature\". Not sure how I want to go about it yet. Suggestions are very much\nwelcome [on the issue](https://github.com/evanthegrayt/cdc/issues/6).\n\n### Ignoring certain directories\nIf you have directories within `CDC_DIRS` that you want the plugin to ignore,\nyou can `export CDC_IGNORE` to a string containing those directories. These\nelements should only be the directory base-name, **not** the absolute path.\n\"Ignoring\" a directory will prevent it from being \"seen\" by `cdc`.\n\n```sh\n# Assuming you never want to `cdc notes_directory`:\nexport CDC_IGNORE=notes_directory:training\n```\n\n### Only recognize actual repositories\nYou can `export CDC_REPOS_ONLY` in a startup file to make `cdc` only recognize\nrepositories as directories. This is **disabled by default**. You can also set\na string of files and directories that mark what you consider a repository.\nNote that markers that are directories must end with a `/`, while files must\nnot.\n\n```sh\n# Enable \"repos-only\" mode. Note, the default is false.\nexport CDC_REPOS_ONLY=true\n# Set repository markers with the following. Note, the following is already the\n# default, but this is how you can overwrite it in ~/.zshrc or similar.\nexport CDC_REPO_MARKERS=.git/:.git:Rakefile:Makefile:.hg/:.bzr/:.svn/\n```\n\nNote that this setting can be overridden with the `-r` and `-R` options. See\n[options](#options) below.\n\n### Automatically pushing to the history stack\nBy default, every `cdc` call will push the directory onto the history stack. You\ncan disable this feature by setting `CDC_AUTO_PUSH` to `false` in a startup\nfile.\n\n```sh\n# Disable auto-pushing to history stack.\nexport CDC_AUTO_PUSH=false\n```\n\nYou can then manually push directories onto the stack with `-u`. If you have\n`CDC_AUTO_PUSH` set to `true`, you can still `cdc` to a directory and not push\nit to the stack with the `-U` option. See [options](#options) below.\n\n### Colored Output\nYou can enable/disable colored terminal output, and even change the colors, by\nadding the following lines to a startup file.\n\n```sh\nexport CDC_COLOR=false               # Default: true. Setting to false disables colors\n# The following lines would make the colored output bold.\nexport CDC_SUCCESS_COLOR='\\033[1;92m'  # Bold green.   Default: '\\033[0;32m' (green)\nexport CDC_WARNING_COLOR='\\033[1;93m'  # Bold yellow.  Default: '\\033[0;33m' (yellow)\nexport CDC_ERROR_COLOR='\\033[1;91m'    # Bold red.     Default: '\\033[0;31m' (red)\n```\n\n## Usage\nTyping `cdc \u003cTAB\u003e` will list all available directories, and this list is built\non the fly; nothing is hard-coded. Hit `return` after typing the directory name\nto change to that directory.\n\nYou *can* append subdirectories, and it will work; however, this is an\nexperimental feature, and I don't have tab-completion working for this yet (any\nhelp with [the issue](https://github.com/evanthegrayt/cdc/issues/2) would be\ngreatly appreciated). For example:\n\n```sh\ncdc repo/bin\n```\n\nIf the subdirectory doesn't exist, it will `cd` to the base directory, and then\nprint a message to `stderr`.\n\n### Options\nThe plugin comes with a few available options. Some are for dealing with the\ndirectory history stack, similar to `pushd`, `popd`, and `dirs`. Others are for\noverriding variables set in a startup file. There's also a debug mode.\n\n|Flag|What it does|\n|:------|:-----------|\n|-a|Allow the plugin to `cd` to ignored directories.|\n|-c|Enable colored output.|\n|-C|Disable colored output.|\n|-l|List all directories to which you can `cdc`. Same as tab-completion.|\n|-L|List the directories in which `cdc` will search.|\n|-i|List the directories that are to be ignored.|\n|-d|List directories in history stack. Similar to the `dirs` command.|\n|-n|`cd` to the current directory in the history stack.|\n|-t|Toggle to the last directory, similar to `cd -`. Rearranges history stack.|\n|-p|`cd` to previous directory in history stack. Similar to the `popd` command.|\n|-u|Push the directory onto the stack. Similar to the `pushd` command.|\n|-U|Do not push the directory onto the stack.|\n|-r|Only `cd` to repositories.|\n|-R|`cd` to the directory even if it's not a repository.|\n|-D|Debug mode. Enables warnings for when things aren't working as expected.|\n|-w|Print the directory location instead of changing to it. Like `which`.|\n|-h|Print help.|\n\n## Reporting bugs\nIf you have an idea or find a bug, please [create an\nissue](https://github.com/evanthegrayt/cdc/issues/new). Just make sure the topic\ndoesn't already exist. Better yet, you can always submit a Pull Request.\n\nIf you have an issue with tab-completion, make sure you have completion enabled\nfor your shell\n([bash](https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion.html)\n/ [zsh](http://zsh.sourceforge.net/Doc/Release/Completion-System.html)). If,\nafter reading the manual, you still have problems, feel free to submit an issue.\n\n## Self-Promotion\nI do these projects for fun, and I enjoy knowing that they're helpful to people.\nConsider starring [the repository](https://github.com/evanthegrayt/cdc) if you\nlike it! If you love it, follow me [on github](https://github.com/evanthegrayt)!\n","funding_links":[],"categories":["Plugins","Shell"],"sub_categories":["ZSH on Windows","Zinit (née zplugin)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanthegrayt%2Fcdc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevanthegrayt%2Fcdc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanthegrayt%2Fcdc/lists"}