Help request: How to set the tab title according to the prompt with Cygwin bash / OSC 2 documentation? #19776
-
|
Hello everybody, I like Windows Terminal very much, and it gets better with every version. I am looking forward to the future development. However, since ages I have a problem that becomes more pain from day to day, so I have now decided to ask for help. Amongst others, I am using Terminal on Windows together with Cygwin (bash) to perform management tasks on remote servers via SSH. I often have a dozen of Terminal tabs open, each containing a session to a different server. In this scenario, I would like each Terminal tab title to be the remote server host name, and to change dynamically if I close the respective session with the host and connect to a new host. The prompt in Cygwin bash is configured so that it contains the host name. For example, if I am connected to host I think that I have understood how the interaction between Terminal and the shell works. The problem is that I can't find any documentation for this specific use case. The only hint about it is in Terminal's UI itself. The help text for the option I am aware that this option must be turned off, but that's not the subject of the question. The key point is the In contrast, (some of?) the But I was not able to spot something similar for the Can somebody please help me out there? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
|
Not sure if I understand the question 100% but I changed tab titles when connecting with ssh by making an ssh wrapper function that just did:
Just grab $1 and split on "@" to get the individual user and host. Is that what you're asking? |
Beta Was this translation helpful? Give feedback.
-
|
@MichaelJOHare Thank you very much! Yes, that's exactly what I was asking. I believe that quite a few guys out there have the same problem, so I'll try to describe the problem in other words. For example, when looking into the link from my first post, we can tell Terminal the working directory by From that, we see that the Therefore, I am very grateful for your code. Obviously, the format is simpler than I suspected. For the record, in terms of the documentation I have linked, the command to set the tab title seems to be Now that I know the correct format, I have changed the prompt definition on a few of the remote systems accordingly, and that works, too. This means that we now have even two methods to solve the problem. |
Beta Was this translation helpful? Give feedback.
-
|
@Binarus Ah, I see what you mean now about the initial confusion over the specific format. I'm glad to hear that answered your question though! |
Beta Was this translation helpful? Give feedback.
-
|
I have just seen that my second post has been selected as answer. But that's an honor that is not due to me, because it's @MichaelJOHare who gave the answer. Therefore I have unmarked the answer and hope that a moderator can mark Michael's first post as answer. For whatever reason, I can't do that myself. |
Beta Was this translation helpful? Give feedback.
Not sure if I understand the question 100% but I changed tab titles when connecting with ssh by making an ssh wrapper function that just did:
printf '\033]2;%s\007' "$user@$host"Just grab $1 and split on "@" to get the individual user and host. Is that what you're asking?