Add opt-in abbr_nix option to abbreviate Nix store paths in Command column - #954
Open
MsfPablo wants to merge 2 commits into
Open
Add opt-in abbr_nix option to abbreviate Nix store paths in Command column#954MsfPablo wants to merge 2 commits into
MsfPablo wants to merge 2 commits into
Conversation
…olumn When display.abbr_nix is enabled, paths under /nix/store/<32-hex-hash>-name are shortened to /nix/store/<hash-12>…-name. The package name and version remain visible so the process is still identifiable, while the hash is truncated enough to reclaim a meaningful amount of horizontal space when many processes carry long store paths in their argv. Closes dalance#686
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.
Implements #686.
Adds a new opt-in config flag,
display.abbr_nix, that abbreviates Nix store paths in the Command column.Behaviour
When
display.abbr_nix = trueis set in the[display]section of the user's config, paths matching the shapeare shortened to
Examples:
/nix/store/abc1234567890def0123456789abcdef-gcc-13.2.0/bin/gcc/nix/store/abc123456789…-gcc-13.2.0/bin/gcc/nix/store/00000000000000000000000000000000-hello-2.12.1/nix/store/000000000000…-hello-2.12.1Non-matching paths (short hashes, non-hex prefixes, anything outside
/nix/store/) are passed through unchanged. The flag is opt-in and defaults tofalse, so existing users see no change.Rationale
The package name (
<name>-<version>) stays fully visible, which is what a user needs to recognise the process — the truncated hash prefix is more than enough to disambiguate between different builds of the same package.Implementation
display.abbr_nixadded toConfigDisplay(mirrors the existingabbr_sidWindows SID abbreviation).Command::newnow takesabbr_nix: bool.raw_contents(the displayed text); the underlyingfmt_contentsis preserved so downstream consumers — search, sort, the raw-mode escape -- still see the full path.Verification
cargo build(with and without default features) — clean.cargo test— 12 passed, 0 failed.cargo fmt --check— clean.cargo clippy— no new warnings introduced.abbr_nix_store_pathover 6 representative inputs (long hex hash, short name, no prefix, empty, prefix-only, non-hex) confirms expected behaviour.