Allow tab title to be updated linux-style #6051

Closed
opened 2026-01-31 00:28:39 +00:00 by claunia · 5 comments
Owner

Originally created by @ErMaqui on GitHub (Jan 20, 2020).

Hi,

A good feature for windows terminal can be allowing update window title as putty does (or any terminal on linux).

I don't know how it's work, but, on bash, there's a configuration for exporting a variable with the window title:

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}: ${PWD/$HOME/~}\007"'
    ;;
*)
    ;;
esac

PuTTY, or any bash opened on linux on x-windows, reads this variable and set the title with it.
That's possible to be implemented on Windows Terminal?

Originally created by @ErMaqui on GitHub (Jan 20, 2020). Hi, A good feature for windows terminal can be allowing update window title as putty does (or any terminal on linux). I don't know how it's work, but, on bash, there's a configuration for exporting a variable with the window title: ``` # If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME}: ${PWD/$HOME/~}\007"' ;; *) ;; esac ``` PuTTY, or any bash opened on linux on x-windows, reads this variable and set the title with it. That's possible to be implemented on Windows Terminal?
claunia added the Issue-QuestionArea-VTResolution-AnsweredProduct-Terminal labels 2026-01-31 00:28:39 +00:00
Author
Owner

@zadjii-msft commented on GitHub (Jan 20, 2020):

This should already work on the Windows Terminal by default - are you not seeing this working? Could you share your profiles.json if it's not working for you?

@zadjii-msft commented on GitHub (Jan 20, 2020): This should already work on the Windows Terminal by default - are you not seeing this working? Could you share your `profiles.json` if it's not working for you?
Author
Owner

@ErMaqui commented on GitHub (Jan 20, 2020):

Hi,

Thanks for your fast response. My profiles.json contains that:

        {
            "acrylicOpacity": 0.75,
            "closeOnExit": true,
            "colorScheme": "One Half Dark",
            "commandline": "ssh <myhost>",
            "cursorColor": "#FFFFFF",
            "cursorShape": "bar",
            "fontFace": "DejaVu Sans Mono for Powerline",
            "fontSize": 10,
            "guid": "{1777cdf0-b2c4-5a63-a204-1111f349ea7c}",
            "historySize": 9001,
            "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png",
            "name": "<myhost>",
            "padding": "0, 0, 0, 0",
            "snapOnInput": true,
            "startingDirectory": "%USERPROFILE%",
            "useAcrylic": true
        },

I've found it on SO (https://stackoverflow.com/questions/57363597/how-to-use-a-new-windows-terminal-app-for-ssh), because I didn't know where is this doc about terminal.

@ErMaqui commented on GitHub (Jan 20, 2020): Hi, Thanks for your fast response. My profiles.json contains that: ``` { "acrylicOpacity": 0.75, "closeOnExit": true, "colorScheme": "One Half Dark", "commandline": "ssh <myhost>", "cursorColor": "#FFFFFF", "cursorShape": "bar", "fontFace": "DejaVu Sans Mono for Powerline", "fontSize": 10, "guid": "{1777cdf0-b2c4-5a63-a204-1111f349ea7c}", "historySize": 9001, "icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", "name": "<myhost>", "padding": "0, 0, 0, 0", "snapOnInput": true, "startingDirectory": "%USERPROFILE%", "useAcrylic": true }, ``` I've found it on SO (https://stackoverflow.com/questions/57363597/how-to-use-a-new-windows-terminal-app-for-ssh), because I didn't know where is this doc about terminal.
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 21, 2020):

In your SSH session, what do you get if you run echo $TERM?

I ask because your title-setting code checks whether TERM begins with xterm or rxvt. If your TERM doesn't, your shell won't even send the title escapes.

@DHowett-MSFT commented on GitHub (Jan 21, 2020): In your SSH session, what do you get if you run `echo $TERM`? I ask because your title-setting code checks whether `TERM` begins with `xterm` or `rxvt`. If your `TERM` _doesn't_, your shell won't even send the title escapes.
Author
Owner

@ErMaqui commented on GitHub (Jan 22, 2020):

On bash on windows, and also on ssh session, $TERM has "cygwin" value. That's the issue.
I've changed it on bash to xterm-color (via .bashrc, on windows bash), but, how can I set this environment prior to opening SSH session trough console? A windows environment, or a config on profiles.json?

I'm asking this because I have a lot of linux machines, and on each one multiple users to configure. It's really more easy if I can do the change on client-side instead of server-side.

Thanks,

@ErMaqui commented on GitHub (Jan 22, 2020): On bash on windows, and also on ssh session, $TERM has "cygwin" value. That's the issue. I've changed it on bash to xterm-color (via .bashrc, on windows bash), but, how can I set this environment prior to opening SSH session trough console? A windows environment, or a config on profiles.json? I'm asking this because I have a lot of linux machines, and on each one multiple users to configure. It's really more easy if I can do the change on client-side instead of server-side. Thanks,
Author
Owner

@DHowett-MSFT commented on GitHub (Jan 22, 2020):

Interesting! "Bash on Windows", if you're referring to WSL, should very emphatically not be reporting TERM=cygwin. On my machine, it reports xterm-256color.

image

If you're using cygwin and cygwin's bash is eclipsing the WSL one, or you're cygwin's ssh instead of the one that ships with Windows, I don't think there's a way to get it to report a different TERM by default.

Incidentally, Cygwin's terminal support is lagging behind even Windows 10's inbox console host, and it may produce unusual or unfortunate results when you use more complicated VT sequences.

@DHowett-MSFT commented on GitHub (Jan 22, 2020): Interesting! "Bash on Windows", if you're referring to WSL, should very emphatically _not_ be reporting `TERM=cygwin`. On my machine, it reports `xterm-256color`. ![image](https://user-images.githubusercontent.com/14316954/72927241-ad056280-3d0a-11ea-85a1-26792f2a0cf5.png) If you're using cygwin and cygwin's `bash` is eclipsing the WSL one, _or_ you're cygwin's `ssh` instead of the one that ships with Windows, I don't think there's a way to get it to report a different `TERM` by default. Incidentally, Cygwin's terminal support is lagging behind even Windows 10's inbox console host, and it may produce unusual or unfortunate results when you use more complicated VT sequences.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6051