Skip to content

feat(setup): multi-shell integration with completions and custom names - #23

Merged
reckerp merged 5 commits into
mainfrom
feat/shell-integration-polish
Jun 29, 2026
Merged

feat(setup): multi-shell integration with completions and custom names#23
reckerp merged 5 commits into
mainfrom
feat/shell-integration-polish

Conversation

@reckerp

@reckerp reckerp commented Jun 29, 2026

Copy link
Copy Markdown
Owner

What

Polishes gx setup so shell integration covers more shells, ships completion, supports custom wrapper names, and handles branch-name globs safely. Implements section 6 (Shell Integration Polish) of the workspace improvement plan.

New CLI surface

gx setup                      # auto-detects shell from $SHELL
gx setup --shell zsh|bash|fish
gx setup --completions zsh    # emit only the static completion script
gx setup --name gx-dev --command /path/to/gx

Changes

  • Multi-shell wrappers: replaced the single POSIX wrapper with shell-specific integration for zsh, bash, and fish. Shell is detected from $SHELL, with --shell as an override.
  • zsh noglob: the zsh wrapper aliases through noglob so branch-name arguments containing glob characters (gx workspace remove feat/*, gx checkout users/[id]) reach gx literally instead of being expanded by the shell.
  • Completion: static command/flag completion is generated via clap_complete, then layered with dynamic helpers that provide live candidates for workspace names, branch names, remote branch names, and stash refs.
  • Custom command names: --name/--command emit integration for a custom wrapper name pointing at a specific binary, useful for developing gx locally while keeping the installed release available as gx.
  • __complete backend: a hidden gx __complete <kind> invocation backs the dynamic completion helpers. It is intercepted in main before clap parses rather than being a clap subcommand, because clap_complete emits even hidden subcommands into the static completion script and would otherwise surface it as a visible gx <TAB> candidate.
  • git helper: added get_remote_branches for remote-tracking branch completion (skips symbolic refs like origin/HEAD).

Conventions honored

  • stdout stays reserved for the eval'd script and the __complete candidate list; all human-facing notices go to stderr.
  • Existing alias generation behavior is kept stable.

Why

gx setup only supported a single POSIX/zsh-style wrapper with no completion and no way to point at an alternate binary. This makes the integration usable across zsh, bash, and fish, adds completion that understands gx's own workspace/branch/stash state, and removes a class of breakage where the shell expanded branch-name globs before gx saw them.

Testing

  • cargo build passes with no warnings.
  • cargo test passes (145 tests). 15 new unit tests cover shell detection, per-shell wrapper contents, noglob presence in zsh, alias rendering and sorting, custom-name substitution, dynamic completion wiring for all four kinds across all three shells, and that the internal __complete helper never leaks into static completion output.

reckerp added 5 commits June 29, 2026 22:01
…backend

Extend the setup subcommand with --shell, --completions, --name, and
--command flags backed by a ShellKind enum scoped to the three supported
shells (zsh, bash, fish). Add a CompleteKind enum for the dynamic
completion candidate kinds.

The internal '__complete <kind>' backend is intercepted in main before
clap parses, rather than being a hidden subcommand, because clap_complete
emits hidden subcommands into the static completion script and would
surface it as a visible candidate.
Add get_remote_branches to back the dynamic completion of remote branch
names for workspace new. Returns remote/branch shorthands and skips
symbolic refs like origin/HEAD.
Replace the single POSIX wrapper with shell-specific integration scripts
for zsh, bash, and fish. Shell is auto-detected from $SHELL with --shell
as an override.

- zsh wrapper uses noglob so branch-name globs (feat/*, users/[id]) reach
  gx literally instead of being expanded by the shell
- bash and fish wrappers handle workspace cd navigation natively
- static command/flag completion is generated via clap_complete and
  layered with dynamic helpers for workspace names, branch names, remote
  branch names, and stash refs
- --name/--command emit integration for a custom wrapper name and binary
  path, useful when developing gx locally alongside the installed release

Human-facing output stays on stderr; stdout carries only the script (meant
to be eval'd) and the __complete candidate list. Includes unit tests for
shell detection, wrapper contents per shell, alias rendering, custom name
substitution, completion wiring, and that the internal __complete helper
never leaks into static completion output.
@reckerp
reckerp merged commit 55bb4a2 into main Jun 29, 2026
6 checks passed
@reckerp
reckerp deleted the feat/shell-integration-polish branch June 29, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant