Add support for title stack via control sequence
Is your feature request related to a problem? Please describe. I noticed that the pane title set by SSH (openssh cli) on Linux does not get reset / reverted when the SSH session finishes.
As a workaround I tried adding a wrapper script that does the below.
- Save the title on stack
- run SSH command with given args, allowing SSH to set whatever title it wants
- When SSH command exits, the last thing the script does is to restore the title from stack.
Details can be found here. https://stackoverflow.com/a/20048874
#!/bin/sh
/bin/echo -ne '\033[22;0t' # Save title on stack
ssh "$@"
/bin/echo -ne '\033[23;0t' # Restore title from stack
The control sequence does not make any difference. I suspect they are not currently supported.
Describe the solution you'd like I would like to see title stacks supported in WezTerm; my favourite terminal app.
Describe alternatives you've considered
I have considered using wezterm cli to do the same, but AFAIK there is no way to get the current title of the current pane.
Additional context None
@wez Is there a workaround for this using the CLI?
Did you try wezterm cli list? It can also output in json.
Thanks, @wez. I didn't know that before. Let me see if I can formulate a workaround.
It would be nice if WezTerm would support the save and restore approach with the escape sequence.
Hi @wez, I tried but no luck.
ssh() {
local saved_title=$(wezterm cli list --format json | q -r ".[] | select(.pane_id==$WEZTERM_PANE) | .title")
command ssh "$@"
wezterm cli set-tab-title "$saved_title"
}
Saving the current pane title does work. wezterm cli set-tab-title is being invoked with the saved value but tab-title does not seem to change.
The command wezterm cli list --format json | jq -r ".[] | select(.pane_id==$WEZTERM_PANE)" gives the below output.
{
"window_id": 1,
"tab_id": 10,
"pane_id": 16,
"workspace": "default",
"size": {
"rows": 65,
"cols": 319,
"pixel_width": 2552,
"pixel_height": 1365,
"dpi": 96
},
"title": "user@host-abc:~", // <-- not changed; set from SSH session
"cwd": "file://host-local/home/user/",
"cursor_x": 0,
"cursor_y": 18,
"cursor_shape": "Default",
"cursor_visibility": "Visible",
"left_col": 0,
"top_row": 0,
"tab_title": "bash", // <-- set by the attemp to restore title
"window_title": "user@host-abc:~",
"is_active": true,
"is_zoomed": false,
"tty_name": "/dev/pts/6"
}
Sorry @wez there was an error in the script I posted .. copy paste error.
The error still.persists; just to be clear.
@wez When you get a chance, can you please review my comments and script above to see if a workaround can be made. Thanks
Sorry, but I have no time or interest in figuring out a workaround. I may consider implementing the stack feature in the future, but as of right now, I'm not spending any more time here.
Is it at all possible to add a cli command for set-panel-title?
I found a solution to this in a similar iterm2 issue. I added precmd () {print -Pn "\e]0;%~\a"}; to my .zshrc so that the shell sets the title to my cwd. You may have to play with the escape sequences to get the title you desire.