Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash: use \w instead of $PWD for the title #4643

Closed
jparise opened this issue Jan 5, 2025 · 2 comments
Closed

bash: use \w instead of $PWD for the title #4643

jparise opened this issue Jan 5, 2025 · 2 comments

Comments

@jparise
Copy link
Collaborator

jparise commented Jan 5, 2025

Discussed in #4601

Originally posted by piki January 4, 2025
The PS1= variable in the bash integration for the title bar could use \w rather than $PWD to indicate the working directory.

The effect is to replace any leading instance of $HOME with a tilde, so /Users/patrick/code becomes ~/code. It also respects $PROMPT_DIRTRIM, if any. It looks cleaner to me, especially if there are multiple tabs open.

Implemented in this branch.


From @jparise:

This sounds like a good improvement to me, and it looks like we do something similar in the zsh shell integration:

builtin print -rnu $_ghostty_fd \$'\\e]2;'\"\${(%):-%(4~|…/%3~|%~)}\"\$'\\a'"

The "set title" command is purely informational, so $PROMPT_DIRTRIM's abbreviation behavior shouldn't cause any functional issues. (We can rely on \e]7;kitty-shell-cwd://.. to report the full current working directory.)

I think it's possible some people might like to further customize their title, but they can do that in through their own shell configuration and disable our "title" shell integration feature.

@jparise
Copy link
Collaborator Author

jparise commented Jan 6, 2025

@piki feel free to create a pull request based on your branch. If you're short on time, I can also make this change.

@piki
Copy link
Contributor

piki commented Jan 6, 2025

@piki feel free to create a pull request based on your branch. If you're short on time, I can also make this change.

Opened as #4656

mitchellh added a commit that referenced this issue Jan 6, 2025
The `PS1=` variable in the bash integration for the title bar could use
[`\w`](https://www.man7.org/linux/man-pages//man1/bash.1.html#PROMPTING)
rather than `$PWD` to indicate the working directory.

The effect is to replace any leading instance of `$HOME` with a tilde,
so `/Users/patrick/code` becomes `~/code`. It also respects
[`$PROMPT_DIRTRIM`](https://www.man7.org/linux/man-pages//man1/bash.1.html#PARAMETERS),
if any. It looks cleaner to me, especially if there are multiple tabs
open.

Implements #4643 (cc discussion #4601).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants