Conversation
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
| local dir=${PWD:t} | ||
| [[ $PWD == $HOME ]] && dir="~" | ||
| print -n "\e]2;zsh:${dir}\a" |
There was a problem hiding this comment.
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'
No description provided.