cdproject
v0.1.3
Published
Fast project directory switch helper
Maintainers
Readme
cdp
cdp ("CD Project") saves paths to directories you work with often.
Instead of cd /long/path/to/your/project, type cdp project.
Explicit naming. No fuzzy matching. No learning period. Just names you choose.
Why cdp?
Tools like zoxide learn your habits over time. cdp takes a different approach:
- You name it —
cdp init apisaves the current directory as "api". No guessing. - It just works — No frequency tracking, no database to maintain, no fuzzy heuristics.
- Team-ready — Export and import configs. Share project shortcuts across machines.
- Minimal — Single config file, atomic writes, no dependencies beyond Node.
Quick Start
cd /path/to/project
cdp init myproject # saves "myproject" -> /path/to/project
cdp myproject # prints /path/to/project
cd myproject # now you're thereInstallation
npm install -g cdprojectShell setup
cdp outputs a path. It needs a shell wrapper to change directories for you.
cdp setup
source ~/.zshrc # or source ~/.bashrcFor tab completion:
cdp setup --completion
source ~/.zshrc # or source ~/.bashrcUsage
Save a project
cd /var/www/api
cdp init apicdp infers the name from the directory if you omit it:
cdp init # saves as "api" if directory is /var/www/apiJump to a project
cdp apiWith the shell wrapper, cd happens automatically. Without it, cdp prints the path:
cdp api # with wrapper: changes directory
# without wrapper: outputs /var/www/apiList all projects
cdp listOutput:
api /var/www/api
web /var/www/webRemove a project
cdp remove old-projectRename a project
cdp rename api backend-apiInteractive mode
Run cdp with no arguments:
cdpShows a numbered list of saved projects. Select by number or name.
Export config
cdp export > backup.jsonPipe to share across machines:
cdp export | ssh other-machine 'cdp import'Import config
cdp import backup.jsonOr from stdin:
cat backup.json | cdp importDiagnose issues
cdp doctorChecks config file, saved paths, and shell integration.
Shell Wrapper
The wrapper intercepts cdp calls and runs cd on the output. Here's what it does:
cdp() {
if [ "$#" -eq 0 ]; then
# Interactive mode
# ...
fi
case "$1" in
init|list|remove|rename|doctor|export|import|help|--help|-h|--version|-v|setup)
command cdp "$@"
;;
*)
cd "$(command cdp "$@")" || return 1
;;
esac
}Add it manually to ~/.zshrc or ~/.bashrc if cdp setup doesn't work.
Configuration
Config lives at ~/.cdp/projects.json.
{
"version": 1,
"projects": {
"api": {
"path": "/var/www/api",
"createdAt": "2024-01-15T10:00:00.000Z",
"updatedAt": "2024-01-15T10:00:00.000Z"
}
}
}Atomic writes prevent corruption if the process is interrupted.
Troubleshooting
"cdp isn't changing directories"
The shell wrapper is missing or not loaded.
grep "cdp()" ~/.zshrcIf empty, run cdp setup again and source ~/.zshrc.
"Project not found"
cdp list # check what exists
cdp doctor # diagnose config and paths"Config corrupted"
cdp export > backup.json # save what you have
rm ~/.cdp/projects.json # delete config
cdp init myproject # recreateInteractive mode not working
Make sure the shell wrapper includes the interactive selection block. If you added cdp() manually, copy the full function from the installation section.
Commands
| Command | Description |
|---------|-------------|
| cdp init [name] | Save current directory |
| cdp list | List all saved projects |
| cdp remove <name> | Remove a project |
| cdp rename <old> <new> | Rename a project |
| cdp setup [--completion] | Add shell wrapper |
| cdp doctor | Diagnose config and integration |
| cdp export | Export config to stdout |
| cdp import [file] | Import config from file or stdin |
| cdp <name> | Jump to project |
License
MIT
