You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
✨ Stop editing users zsh file in order to set the terminal tab title #1640
I am using xonsh which will source zshrc from its own rc file. However, I found the current shell integration injection (the code below) breaks the zsh grammar.
@TeddyHuang-00 I'd agree, and if possible I'd like to avoid modifying the rc files in the first place.
I think this was put in place to attempt to label the tab that represented each terminal in the utility area. I honestly think that there is a better way to do this that doesn't require us to modify the users rc file.
I honestly think that there is a better way to do this that doesn't require us to modify the users rc file.
@austincondiff Yes, there are definitely methods out there that can achieve this without messing with rc files. Existing terminal emulators like iTerm2 and alacritty are able to do this without modifying the rc files.
I tracked the dialogue a little bit, and can tell that all the shell integration does is to add hooks before and after command execution to raise escape sequences for CodeEdit to process.
I suspect that by setting the terminal type $TERM to some well-established values (e.g. xterm-256color) will automatically raise those escape sequences, though the exact escape sequences might differ based on this value chosen.
Due to my lack of knowledge in this project and Swift, I cannot offer any further help in implementing this, but I honestly think this is a more rational way to achieve this and hope it will be adopted.
changed the title [-]Improve shell integration[/-][+]✨ Stop editing users zsh file for setting the terminal title as the terminal tab title[/+]on Mar 23, 2024
At the moment, following the weekly meeting today, we decided to directly fix this issue by no longer write anything in user's rc file. So this syntax won't be fixed in a short period of time (or forever if everything goes well).
Shell Integration scripts
As far as I can tell, hook scripts (like codeedit_shell_integration.zsh that we have right now) are required. No $TERM settings will enable this or add any escape sequence, it's all terminal app developers' work.
As a reference, here's what VSCode and iTerm2 are doing.
What's the fix?
As our entire approach is more similar to iTerm, we might try to use a similar solution to theirs. Here's their code.
changed the title [-]✨ Stop editing users zsh file for setting the terminal title as the terminal tab title[/-][+]✨ Stop editing users zsh file in order to set the terminal tab title[/+]on Mar 24, 2024
After doing some research, it looks like iTerm2 does require users to edit their rc file manually to use their terminal integration feature (docs). What VSCode does (and what seems like a good option) is they set the init file to a temporary directory which includes their own init files. These scripts have hooks for a few VSCode features, and eventually source the user's init files after setting up their own (VSC's rc.zsh file, Where shell injection happens). Or, for bash, they emulate what bash does for init. They pass their own script as the init file, and then execute the user's init file depending on what exists (bash_profile, bash_login, then profile, see this file)
I have this working and tested for both bash and zsh. I'll open a PR later today. We'll also enable users to opt-out of using the injection mechanism in settings.
Activity
austincondiff commentedon Mar 19, 2024
@TeddyHuang-00 I'd agree, and if possible I'd like to avoid modifying the rc files in the first place.
I think this was put in place to attempt to label the tab that represented each terminal in the utility area. I honestly think that there is a better way to do this that doesn't require us to modify the users rc file.
See this issue for context.
TeddyHuang-00 commentedon Mar 19, 2024
@austincondiff Yes, there are definitely methods out there that can achieve this without messing with rc files. Existing terminal emulators like iTerm2 and alacritty are able to do this without modifying the rc files.
I tracked the dialogue a little bit, and can tell that all the shell integration does is to add hooks before and after command execution to raise escape sequences for CodeEdit to process.
I suspect that by setting the terminal type
$TERMto some well-established values (e.g. xterm-256color) will automatically raise those escape sequences, though the exact escape sequences might differ based on this value chosen.Due to my lack of knowledge in this project and Swift, I cannot offer any further help in implementing this, but I honestly think this is a more rational way to achieve this and hope it will be adopted.
[-]Improve shell integration[/-][+]✨ Stop editing users zsh file for setting the terminal title as the terminal tab title[/+]Qubik65536 commentedon Mar 23, 2024
@austincondiff Can you assign this to me please?
Qubik65536 commentedon Mar 23, 2024
Here's a simple progress report.
What we'll do
At the moment, following the weekly meeting today, we decided to directly fix this issue by no longer write anything in user's rc file. So this syntax won't be fixed in a short period of time (or forever if everything goes well).
Shell Integration scripts
As far as I can tell, hook scripts (like
codeedit_shell_integration.zshthat we have right now) are required. No$TERMsettings will enable this or add any escape sequence, it's all terminal app developers' work.As a reference, here's what VSCode and iTerm2 are doing.
What's the fix?
As our entire approach is more similar to iTerm, we might try to use a similar solution to theirs. Here's their code.
[-]✨ Stop editing users zsh file for setting the terminal title as the terminal tab title[/-][+]✨ Stop editing users zsh file in order to set the terminal tab title[/+]thecoolwinter commentedon Jun 2, 2024
After doing some research, it looks like iTerm2 does require users to edit their rc file manually to use their terminal integration feature (docs). What VSCode does (and what seems like a good option) is they set the init file to a temporary directory which includes their own init files. These scripts have hooks for a few VSCode features, and eventually source the user's init files after setting up their own (VSC's rc.zsh file, Where shell injection happens). Or, for bash, they emulate what bash does for init. They pass their own script as the init file, and then execute the user's init file depending on what exists (
bash_profile,bash_login, thenprofile, see this file)thecoolwinter commentedon Jun 11, 2024
I have this working and tested for both
bashandzsh. I'll open a PR later today. We'll also enable users to opt-out of using the injection mechanism in settings.