Skip to content

fix(zsh): Fix p10k's title#3838

Merged
yutkat merged 1 commit intomainfrom
v49.133
Apr 9, 2026
Merged

fix(zsh): Fix p10k's title#3838
yutkat merged 1 commit intomainfrom
v49.133

Conversation

@yutkat
Copy link
Copy Markdown
Owner

@yutkat yutkat commented Apr 9, 2026

No description provided.

Copilot AI review requested due to automatic review settings April 9, 2026 06:17
@yutkat yutkat merged commit 6c122e1 into main Apr 9, 2026
2 checks passed
@yutkat yutkat deleted the v49.133 branch April 9, 2026 06:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Zsh precmd hook that sets the terminal window title so it no longer relies on prompt escape expansion, and instead derives a short directory label directly from $PWD (with ~ for $HOME), addressing incorrect titles under p10k.

Changes:

  • Replace %1~ prompt escape usage with ${PWD:t} to compute the title directory name.
  • Normalize the title to ~ when the current directory is $HOME.
  • Remove stray blank lines at the end of the hook setup.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the precmd_prompt function in .config/zsh/rc/function.zsh to manually construct the terminal title based on the current working directory, replacing the previous use of zsh's %1~ expansion. The reviewer identified a bug where the root directory (/) is not correctly displayed in the title, and also noted a potential issue with print -n misinterpreting backslashes in directory names. A code suggestion was provided to address these issues.

Comment on lines +243 to +245
local dir=${PWD:t}
[[ $PWD == $HOME ]] && dir="~"
print -n "\e]2;zsh:${dir}\a"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The manual implementation of the directory name logic introduces a minor bug: when the current working directory is the root directory (/), ${PWD:t} evaluates to an empty string, resulting in a terminal title of zsh:.

Additionally, using print -n without the -r flag causes print to interpret any backslashes that might be present in the directory name (e.g., a directory named foo\bar). For better robustness, consider handling the root case and using print -rn with literal escape sequences.

		local dir=${${PWD:t}:-/}
		[[ $PWD == $HOME ]] && dir="~"
		print -rn $'\e]2;zsh:'"${dir}"$'\a'

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.

2 participants