feat(shell): open and complete project_open projects anywhere under ~/Code#204
Conversation
There was a problem hiding this comment.
Pull request overview
Adds interactive shell autocompletion for the project_open function (and its po alias) across Bash and Zsh, using shared helper functions to discover WordPress projects and their immediate subdirectories under ~/Code/wordpress.
Changes:
- Add shared discovery helpers (
_project_open_projects,_project_open_targets) inshell/aliases. - Register Bash completion via
complete -F ...forproject_openandpo. - Add Zsh completion function (via deferred
eval) and register it withcompdefwhen available. - Add a design/spec document describing goals, architecture, and manual testing steps.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
shell/aliases |
Implements project/target discovery and wires up Bash + Zsh completion handlers for project_open/po. |
docs/superpowers/specs/2026-06-19-project-open-autocomplete-design.md |
Documents design goals, behavior, and manual testing approach for the new completions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4169d25 to
3c982ae
Compare
4060c26 to
cf2b9ed
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
shell/aliases:371
project_open <name> themeused to be handled as a special case (jumping to the first Composer theme). With the new early return on any second argument,themeis now treated as a literal subdirectory and will try tocd "${NEW_PATH}/theme", which is likely wrong and a behavior regression.
if [ -n "${2}" ]; then
# shellcheck disable=SC2164
cd "${NEW_PATH}/${2}"
return
fi
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
shell/aliases:369
project_openpreviously special-cased a second argument oftheme(skipping the genericcd "${NEW_PATH}/${2}"and instead resolving a composer-based theme directory). With the new unconditional[ -n "${2}" ]early-return,project_open <wp-project> themewill now try tocdinto a literaltheme/subdirectory and never reaches any theme lookup. Ifthemeis still a supported subcommand, reintroduce the special-case and theme resolution after the bedrock/site descent.
if [ -n "${2}" ]; then
# shellcheck disable=SC2164
cd "${NEW_PATH}/${2}"
return
fi
Summary
Generalize
project_open/poto open and tab-complete projects discovered anywhere under~/Code(not just~/Code/wordpress), backed by an on-disk cache, with Bash and Zsh autocompletion.Changes
~/Codeat<category>/<project>depth: any such directory holding a.gitis a project (nested submodules sit deeper and are excluded). Resolve a project by basename.$XDG_CACHE_HOME/project_open/(the filename is keyed by root, so a differentPROJECT_OPEN_ROOTnever reads a stale cache), built asynchronously on interactive shell startup when absent and then kept untilpo_refreshrebuilds it. Root is overridable viaPROJECT_OPEN_ROOT.project_open <name>opens a project found anywhere under~/Code. With no second argument it keeps the existing WordPressbedrock/sitedescent; with a second argument itcds into that literal<subdir>of the project root (no descent), matching the prior behaviour. The two were never combined; the oldthemespecial-case is removed.#compdeffunction on$fpath(shell/completions/_project_open) forproject_openandpo. First-argument (project name) completion reads the cache; second-argument completion lists the resolved project's immediate subdirectories via a shallowfind.Testing
tests/project_open.bats(BATS) covers discovery, cache build/refresh, name resolution, completion helpers, and runtime navigation. Run with./tests/bats/bin/bats tests/*.bats; now wired into CI alongside ShellCheck and stylua.shellcheck shell/aliasesandzsh -n shell/aliases.