Intelligent, width-aware directory shortening - #110
Merged
Merged
Conversation
One central path-display policy (src/prompt/pathDisplay.ts) replaces the ad-hoc HOME substitution. The live prompt tries shortening levels in order and uses the first whose full prompt fits: parents above the repository abbreviate to their shortest unambiguous sibling prefix, then directories inside the repository, then runs collapse to an ellipsis, then only the final directory remains. The repository name and final directory stay whole, HOME stays ~, and prompt snapshots keep the full width-independent path. Abbreviations are resolved asynchronously alongside the prompt context; nothing changes the cwd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #71
What
src/prompt/pathDisplay.ts. It is display only and never changes the cwd.0. full:
~/Projects/work/notMyShell/src/prompt~/P/w/notMyShell/src/prompt~/P/w/notMyShell/s/prompt…/notMyShell/…/prompt…/prompt(the project module already names the repo)readdirof ancestors, and fall back to the first character. Hidden directories keep their dot.~, and a sibling of HOME is not treated as HOME.PromptContextgainsrootandpathAbbreviations. Prompt snapshots keep the full, width-independent path, so history stays stable.Verification
npm run build,npm run typecheck,npm test,git diff --check.tests/pathDisplay.test.tscovers every level, non-repo paths, HOME,/, trailing slashes, hidden directories, unique-prefix resolution against a real temporary tree, the exact-width sweep 20–160, and snapshot stability.The behavior is fully deterministic and tested at the string level, so no terminal-specific behavior is involved.