Skip to content

Share Git-directory and branch lookup between Bash and Zsh prompts #2306

Description

@codeforester

Goal

Move the shell-neutral Git/HEAD lookup into the existing common defaults boundary and keep shell-specific prompt expansion, escapes, options and key bindings in the Bash/Zsh files.

Background

Repository-wide duplication review against f9c18f3294873cbbcda9acc7af7f1bc6b17eed45 (2026-09-17).

The Bash and Zsh defaults duplicate the Git-directory ancestor walk, gitdir-file handling and HEAD-to-branch formatting. The directory functions are identical after the function name, and the prompt functions differ almost only in their helper prefix. Both already load the shell-neutral base_defaults.sh boundary.

Verified source locations:

No matching open issue was found in the repository backlog.

This is a maintainability refactor. Similarity alone is not evidence of a production failure; any demonstrated differences are called out above.

Scope

Move the shell-neutral Git/HEAD lookup into the existing common defaults boundary and keep shell-specific prompt expansion, escapes, options and key bindings in the Bash/Zsh files.

Acceptance Criteria

  • A single implementation handles ordinary repos, worktrees/submodules with gitdir files, detached HEAD and nonrepos.
  • Preserve output and avoid adding Git subprocesses to prompt rendering.
  • Preserve interactive-only loading and source guards.
  • Prove the helper works in both Bash and Zsh, including spaces in checkout paths.

Validation

Run shell-defaults/profile BATS coverage under Bash and Zsh; compare branch labels for normal, linked worktree, detached and malformed/unreadable Git metadata fixtures.

Run focused checks first, then the repository-required broader checks for the actual implementation. Preserve public command contracts and review .ai-context/ impact in the PR.

Non-Goals

No unification of PS1/PROMPT syntax, history settings, key bindings or baserc guard implementations.

Project Fields

  • Status: Ready
  • Priority: P3
  • Area: Shell
  • Initiative: Contract Hardening
  • Size: S
  • Milestone: Unscheduled; no release commitment is implied by this audit.

Agent Assignment

Implementation-ready scoped follow-up, assigned to codeforester. Follow AGENTS.md and docs/github-workflow.md: start through basectl gh issue start, use the canonical issue worktree, characterize current behavior before extraction, and open an issue-linked PR. Keep each refactor independently reviewable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or product improvement

Type

No type

Projects

  • Status
    Done

Relationships

None yet

Development

No branches or pull requests

Issue actions