-
Notifications
You must be signed in to change notification settings - Fork 424
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
Make title bar work out-of-the-box with Gnome Terminal #609
Comments
I'm not sure that there is a "default bash title". Bash by default doesn't interact with a terminal or terminal emulator much, if at all. For it to do so, you need to print out ANSI escape codes to tell the terminal to do something. My guess is that there is some system PS1 or similar in What you see right now ("Terminal") is what happens when no terminal is set, which is the default for Gnome terminal. For Mintty, the default title is the launched command ( Your workaround obviously works fine, but for Liquidprompt v1, the recommended way to set the title would be to write your own
I would agree with your statement that the default Liquidprompt title as it stands right now isn't very useful. I'd like to see a default that doesn't copy PS1 so closely. This is as good as any issue to discuss my plans with the title:
And I'm glad to hear people are still recommending this project! With the 4 year long development hiatus, I know some people have lost interest, but I'm hoping to put some real work in and get this project back on track. |
Now after some thought, I think the title bar by default should be as short as possible to avoid clutter, and in general to start with the most significant information (instead of just username and host). The most significant information from a prompt is:
The username and hostname are interesting mostly only if I am connected to a remote host, but in those cases the remote host bash prompt overrides the window title with it's own signal anyway, so my local Liquid Prompt settings don't matter much in those cases. |
If you have But thanks to you I have improved the title capabilities in v2.0.0-beta.1. You have two options (if you don't like the default title):
lp_title '\H:\w' NOTE: This will no longer work: prompt escape sequences like
Me too! I'm hoping to add such a feature before v2.0.0 final. |
Cool, looking forward to 2.0
|
Here is my design:
It would look like this:
then with a command:
Here is the problem: there is no way to postpend to the current terminal title. To set a title, you must set the whole thing. And to set a title, you must print it to the terminal screen (where the terminal sees the escape sequence and captures it without the user seeing it). The second problem is that if you want to include time, username, hostname, working directory, or current prompt mark in the title, they must be first processed by the shell. The example title above is not printed directly, it would instead look like this:
or in Zsh
This sequence is interpreted by the shell when it reads Other things that don't work:
So there is no easy solution, but I have a possible solution: remove all prompt escape sequences. Some pros and cons: Pros:
Cons:
Spitballing, any thoughts? |
Thanks for looking into this. I have no special thoughts at this time.
I have happily been using Liquid Prompt since June and I have the path and
hostname in the Gnome Terminal prompt, and for now that is enough. Maybe
making it more fancy is not worth it if the typical command line programs
don't have good facilities for it.
|
I'm moving this to v2.1, since v2.0 is getting large and long already, and this mostly depends on #651, which really should wait until after v2.0. |
This feature depends on the removal of the prompt escape sequences that came before. Part of that is the removal of adding the title to $PS1: now it is just print to the screen. This could improve speed slightly, as the shell doesn't need to parse that text. But it does prevent usage of prompt escape codes in the title. I also needed to rework how the runtime feature was handled, since it monopolized the DEBUG trap in Bash. Now it can handle multiple features that need to run after the user has submitted the command, but before it runs. The feature itself is simple: lookup the latest command in the history, and print the normal title postpended by that command to the screen, formatted as a terminal title. Note that Bash's $BASH_COMMAND is not great, as it only contains the current _command_, not the whole command line. Resolves #609
I have pushed a commit (1044321) on branch title-command that adds a feature to display the currently running command as part of the terminal title. It works pretty much exactly like how I described above. I would appreciate it if you could test it and let me know what you think. |
It works in macOS, though I can't figure out why. I don't understand the |
Never mind. It looks like it works exactly the same in my macOS |
That part was inspired by bash-preexec: https://github.com/rcaloras/bash-preexec/blob/10b41c5ed8dc28fe5bb6970cb8e12e618aa5a998/bash-preexec.sh#L230 It is actually entered into the shell history instantly, that's why running I checked Bash 3.2 - 5.1 and the format stayed the same. Does |
Yeah, |
Shoot, so that means there can be no spaces at the beginning. Makes sense, but also makes it much harder to do with parameter substitution and not regex. I can't use regex without calling another process, which would slow this down. I'll try to figure something out.
Yes, the whole command line. This is the only thing I could get working in Zsh, so this way it is consistent. I could use
The first point is fine, and some might prefer it, but the second point is probably never what anyone wants. To show the whole command line instead is just a safer and more consistent with Zsh approach. |
@augmentedfourth I pushed an amended commit (0c23a33) that fixes that issue. I added test cases to catch that now. |
This feature depends on the removal of the prompt escape sequences that came before. Part of that is the removal of adding the title to $PS1: now it is just print to the screen. This could improve speed slightly, as the shell doesn't need to parse that text. But it does prevent usage of prompt escape codes in the title. Which causes a rare issue where __lp_escape() adds duplicate backslashes or percents to escape a string for the prompt, but now are not needed in the title. It will just print double in the title, so it isn't a huge issue, but is something that should be fixed. I'm not sure how to handle it though, since the current architecture requires escaping the strings before formatting is added to them. I also needed to rework how the runtime feature was handled, since it monopolized the DEBUG trap in Bash. Now it can handle multiple features that need to run after the user has submitted the command, but before it runs. The feature itself is simple: lookup the latest command in the history, and print the normal title postpended by that command to the screen, formatted as a terminal title. Note that Bash's $BASH_COMMAND is not great, as it only contains the current _command_, not the whole command line. Resolves #609
Shell: bash
Operating system: Ubuntu 20.04
Liquid Prompt version (tag, commit): 1.11 Debian revision 3 (includes customized settings, see https://sources.debian.org/src/liquidprompt/1.11-3/debian/patches/debian-default-cfg.patch/)
I recently learned about liquidprompt on the Debian developer mailing list and I love it after using for some weeks now.
The only problem seems to be that the Gnome Terminal window title is not set by default:
![image](https://user-images.githubusercontent.com/668724/85776795-b7001700-b729-11ea-97bb-b6eceef857c9.png)
I can enable it manually with
![image](https://user-images.githubusercontent.com/668724/85777062-f3337780-b729-11ea-8069-4afb7e3130d3.png)
LP_ENABLE_TITLE=1
but it does not feel as usable as the rest of liquidprompt since the title bar has excess info that is not relevant for a title bar:In the title bar it would be enough to show what Bash shows by default (mainly user, host and path). Having time or temperature or git branch etc in the title bar does not feel very useful.
Could liquidprompt be made so that it does not override the title with nothing and instead keeps the default bash title there?
If feel that would be the optimal solution from an usability point of view.
This is partially a duplicate of #78 but I thought a new issue would be in place for discussing further development of the title bar feature.
Thanks for a great piece of software!
The text was updated successfully, but these errors were encountered: