Skip to content

Add opt-in abbr_nix option to abbreviate Nix store paths in Command column - #954

Open
MsfPablo wants to merge 2 commits into
dalance:masterfrom
MsfPablo:fix/abbr-nix-store-paths
Open

Add opt-in abbr_nix option to abbreviate Nix store paths in Command column#954
MsfPablo wants to merge 2 commits into
dalance:masterfrom
MsfPablo:fix/abbr-nix-store-paths

Conversation

@MsfPablo

Copy link
Copy Markdown

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 = true is set in the [display] section of the user's config, paths matching the shape

/nix/store/<32 hex chars>-<name>-<version>/...

are shortened to

/nix/store/<hash[:12]>…-<name>-<version>/...

Examples:

Before After
/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.1

Non-matching paths (short hashes, non-hex prefixes, anything outside /nix/store/) are passed through unchanged. The flag is opt-in and defaults to false, 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_nix added to ConfigDisplay (mirrors the existing abbr_sid Windows SID abbreviation).
  • Command::new now takes abbr_nix: bool.
  • The transformation runs only on raw_contents (the displayed text); the underlying fmt_contents is 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.
  • Standalone unit test of abbr_nix_store_path over 6 representative inputs (long hex hash, short name, no prefix, empty, prefix-only, non-hex) confirms expected behaviour.

MsfPablo and others added 2 commits August 11, 2026 15:29
…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
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