Feat: Add ability to toggle zsh-integration title change #4479
+22
−2
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.
When changing the current surface's title via ANSI escape escape sequences (
\e]0;My Custom Title Here\a
or\e]2;My Custom Title Here\a
), the zsh shell integration's_ghostty_precmd
and_ghostty_preexec
functions automatically overwrite it (I spent the better part of today tearing my head out and searching through the code thinking this was a bug in the terminal itself). This functionality can be disabled, however it must be disabled before the shell finishes loading and cannot be re-enabled (or disabled) at a later point.To work around this, a new environment variable has been added (only to the zsh integration for now):
GHOSTTY_SHELL_INTEGRATION_TOGGLE_TITLE_OFF
. This is settable by scripts and commands to disable the zsh integration's overwriting of the title and can be unset to re-enable the functionality.To take advantage of this, I have the following functions enabled in my .zshrc:
After taking a cursory look at the bash I don't believe this same method will be possible there (as it works by setting $PS0 and $PS1 to send the escape sequences).
For elvish I don't know enough to add the desired functionality.
If someone wants to add the code for the other supported shells, or suggest how I might go about fixing them I would be more than happy to include / create it.