Skip to content
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

We should add a tutorial for using OSC9;9 #285

Closed
zadjii-msft opened this issue Mar 19, 2021 · 10 comments · Fixed by #449
Closed

We should add a tutorial for using OSC9;9 #285

zadjii-msft opened this issue Mar 19, 2021 · 10 comments · Fixed by #449
Assignees
Labels
tips-and-tricks Guides that should be added to the "Tips and Tricks" page

Comments

@zadjii-msft
Copy link
Contributor

Kinda like setting the tab title. How you use it varies based on the shell used. Plus, you must use duplicateTab or the duplicate splitPane mode. People have had issues with it everywhere: microsoft/terminal#8330 (comment), microsoft/terminal#3158, et. al. It'll be easier just to have a doc to point people at.

@skyline75489
Copy link

Part of me feel "finally, about time" but another part of me feel "maybe the doc from ConEmu is good enough?" But generally I think we need a guide to point people at, even it just points to ConEmu doc instead.

@TBBle
Copy link
Contributor

TBBle commented Sep 3, 2021

I don't think we can point at the ConEmu docs because they sometimes rely on either ConEmuC.exe or checking for ConEmu -specific env-vars, and explaining the difference seems like more work and less clarity than just stealing replicating the working examples from that page and the microsoft/terminal#3158 comments.

Even the zsh option, which uses a zsh-native plugin, might not work if that plugin is internally checking for ConEmu before activation.

@3N4N
Copy link

3N4N commented Oct 7, 2021

I got a solution for powershell from some github issue. (There are so many issues related to this!) I can't remember exactly which. It basically added "Write-Host "$esc]9;9;`$pwd.ProviderPath`"$esc" -NoNewline" after the prompt. This fix works, but for some reason my WT crashes. I didn't know it was because of this, but I've commented out this fix for two days and it hasn't crashed yet. Whereas with this fix included, WT crashed twice/thrice a day.

@TBBle
Copy link
Contributor

TBBle commented Oct 8, 2021

@3N4N: Try putting \ (or \\, not sure about escaping) after the $esc. It's possible you've hit a bug in the parser: your OSC 9;9 command is missing the terminator, but shouldn't crash WT. If that fixes it, I'd suggest opening a new issue to track the crash.

If that doesn't fix it, still open a new bug report for WT crashing, otherwise it'll just get lost in the comments on this issue.

@3N4N
Copy link

3N4N commented Oct 9, 2021

@TBBle, I started using the preview build of WT and it hasn't crashed yet, without having to escape after $esc. I don't know why. Just reporting.

And what's this missing terminator? I'm asking because when I use grep from git-for-windows from powershell, not by itself like grep 'pattern', but by piping like dir | grep 'pattern', and there is no match, then the prompt is filled with that $esc bla bla stuff. I have to press enter. I wonder if it's because of not having a terminator.

In fact, would you mind sharing your prompt config? That would be much easier for me.

@TBBle
Copy link
Contributor

TBBle commented Oct 9, 2021

It's almost certainly because of the missing terminator. The OSC 9;9 string is $esc]9;9;<dirnamehere>$esc\, where $esc] is known as OSC (Operating system command) and $esc\ is ST (String Terminator).

Without the ST, Windows Terminal has to guess where the string ends. Since your prompt ends in $esc, then whatever happens to be output next will be taken as a possible command, which is probably why you sometimes do things and get a bunch of stuff dumped to the screen, because it's triggering one of the "query" commands where WT responds to the program with some information, but because the shell isn't expecting that, you get it on screen instead.

The reason I'm curious about the crash is that it suggests either: Sometimes the next command is one that crashes WT (bad), or that sometimes the next thing makes it look like it's not a command, and so WT takes a lot of the following data as the working directory and crashes, perhaps because it's too long (also bad).

But without a clear repro case (which as I mentioned, should be in a new bug so we can track it separately from the documentation work), I'm just guessing.

My configuration probably won't help you, since I'm using PowerLine, but you probably want something like microsoft/terminal#3158 (comment) or microsoft/terminal#3158 (comment).

@3N4N
Copy link

3N4N commented Oct 10, 2021

I actually had your suggestion in my config. I got it from ConEmu IIRC.

    if ($env:WT_SESSION) {
        if ($loc.Provider.Name -eq "FileSystem") {
            $out += "$([char]27)]9;9;`"$($loc.Path)`"$([char]7)"
        }
    }

But the grep issue persists. Same result with the other solution

Result of your prompt suggestion:

ACER@DESKTOP-5F09VFS ..\ACER\
PS> dir | grep -i 'patt'

ACER@DESKTOP-5F09VFS ..\ACER\
PS> ←]9;9;"C:\Users\ACER"

Result of LuanVSO's prompt suggestion:

PS C:\Users\ACER> dir | grep -i 'patt'
←]9;9;C:\Users\ACER←\PS C:\Users\ACER>

@TBBle
Copy link
Contributor

TBBle commented Oct 10, 2021

Depending on your Git For Windows setup, I wonder if it's disabling VT processing when grep terminates, and hence causing WT to not see the codes correctly?

I'm also unsure why is here. Assuming it wasn't corrupted by cut-and-paste, that's U+2190 or E2 86 90 in UTF-8, so I don't know why you're seeing that instead of whatever ESC would look like (i.e 0x27), but maybe that's a rendering thing.

It didn't replicate for me, so perhaps your Git needs upgrading, if it's too old (technically, using a too-old cygwin) to handle Windows VT support correctly.

If you're still having issues, I really really really suggest opening a new ticket describing your problem with repros and configs, as the last few OSC 9;9 feature tickets have drowned in support discussion.

image

@3N4N
Copy link

3N4N commented Oct 18, 2021

@TBBle, got a crash right now in WT preview. Not from pwsh, though. I started using cmd with osc9;9 string. Does WT save any log somewhere?

@TBBle
Copy link
Contributor

TBBle commented Oct 18, 2021

The WT Bug Report template should guide you in the right direction for submitting crash logs, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tips-and-tricks Guides that should be added to the "Tips and Tricks" page
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants