Skip to content

Fix path corruption when directory name contains a colon#75

Open
kriansa wants to merge 1 commit intojorgebucaran:mainfrom
kriansa:fix-colon-sentinel
Open

Fix path corruption when directory name contains a colon#75
kriansa wants to merge 1 commit intojorgebucaran:mainfrom
kriansa:fix-colon-sentinel

Conversation

@kriansa
Copy link

@kriansa kriansa commented Mar 13, 2026

Problem

When the current directory name contains a colon (when using git worktrees, e.g. repo:branch-name), the prompt duplicates parts of the path.

For example, inside a directory named core-backend:fix-something:

Expected: ~/Projects/core-backend:fix-something
Actual:   ~/Projects/core-backendcore-backend:fix-somethingfix-something

Cause

_hydro_pwd uses : as a temporary sentinel when abbreviating the git root in the displayed path (lines 24 and 28 of conf.d/hydro.fish):

  1. Line 24 replaces /$git_base/ with :/ — using : as a placeholder
  2. Line 28 replaces : back with $git_base

When the directory name already contains a literal colon, step 2 matches it instead of the sentinel, replacing it with $git_base and corrupting the output.

Fix

Replace the : sentinel with \x1e (ASCII Record Separator), a non-printable character that cannot appear in filesystem paths.

The `_hydro_pwd` function uses `:` as a temporary placeholder when
abbreviating the git root in the displayed path. If the directory name
itself contains a colon (e.g. git worktrees named `repo:branch`), the
replacement on the second `string replace` matches the literal colon
instead of the sentinel, corrupting the path by duplicating segments.

Replace the `:` sentinel with `\x1e` (ASCII Record Separator), which
cannot appear in filesystem paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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