feat(config): configurable window-title and tab-title format strings#798
Open
HermeticOrmus wants to merge 1 commit into
Open
feat(config): configurable window-title and tab-title format strings#798HermeticOrmus wants to merge 1 commit into
HermeticOrmus wants to merge 1 commit into
Conversation
Adds Config.window_title_format (default `"{title} — {app}"`) and
Profile-overridable Config.tab_title_format (default empty = use the
shell-set title verbatim). Substitution placeholders: {title}, {cwd},
{cwd_basename}, {app}.
The current working directory was already plumbed via OSC 7 into
Self::active_terminal_working_directory(); this surfaces it in the
title bar so the format can include it. Default behaviour unchanged.
Useful for users who want the cwd visible without running `pwd` (e.g.
`window_title_format = "{cwd_basename} — {title}"` matches the Ghostty
default).
Refs: pop-os#720
6 unit tests for render_title_format covering known placeholders,
unknown placeholders left alone, missing-cwd, and the edge case where
{cwd_basename} contains "cwd}" so substitution order matters.
Member
|
The PR template is mandatory |
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.
Why
Refs #720. cosmic-term already ingests OSC 7 (working directory) for the new-tab-cwd-inherit feature, but never surfaces it in the window or tab title. Users who want to see what directory the active shell is in have to run `pwd`. Ghostty's default title format includes the cwd; alacritty supports `window.title` formatting; cosmic-term should match.
What changed
`src/config.rs` gains two fields:
Both accept the placeholders `{title}`, `{cwd}`, `{cwd_basename}`, `{app}`.
`update_title()` in `src/main.rs` calls a new `config::render_title_format` helper to substitute. Defaults reproduce the existing UX exactly — no behaviour change unless the user opts in.
Example user config that mirrors Ghostty's default:
```ron
window_title_format: "{cwd_basename} — {title}",
tab_title_format: "{cwd_basename}",
```
How to test
```bash
cargo build --bin cosmic-term
cargo test --bin cosmic-term config::tests::
6 tests: substitutes title+app, substitutes cwd, cwd_basename, missing cwd,
unknown placeholders left alone, substitution order edge case
```
All 6 pass locally on Linux x64.
Manual:
Notes