Closed floh96 closed 3 years ago
That's an easy addition. Can do.
@JanDeDobbeleer do i need to configure it? it's not working in powershell 7 on windows 10 in windows terminal preview (1.6). (without oh-my-posh i added this to my profile and it's working fine.)
@floh96 you updated right? I didn't validate it yet, but that's exactly what's added to the prompt now.
yeah i'm using version 3.89.0
I'll check this evening maybe I did something stupid
Alright I'll go ahead and ask. I skimmed the linked issues, and the PR Jan wrote, and I don't get it. ELI5, what's OSC 9;9?
@TravisTX it's an ansi escape sequence that informs the terminal (windows terminal and conemu are supporting it) about the current working directory. When your current working directory is C:\Users for example and you are duplicating your tab in windows terminal with ctrl+shift+d (the keybinding is not bound in the default configuration, you must manually add it to your settings.json in windows terminal) the working directory of the new tab is also C:\Users.
I built OMP3 from source, the way I usually do, and can confirm this isn't working for me either. I confirmed OMP3 is emitting something that looks correct with my limited knowledge of this. Here's the output, base64 encoded:
G105Ozk7QzpcUHJvamVjdHNcUGVyc29uYWxcb2gtbXktcG9zaDNcc3JjGzc=
CTRL+SHIFT+D opens a new tab with my normal starting directory. Windows Terminal Version: 1.5.10411.0 PowerShell 7.1.2
@TravisTX it's only supported in the windows terminal preview version (1.6) atm i should have mentioned that
Test preview also. Same result. Windows Terminal Preview Version: 1.6.10412.0
Maybe the quotes are required.
yeah i think the quotes are required see https://github.com/microsoft/terminal/pull/8934#issuecomment-769587247 Edit: I don't think the quotes are the problem see https://github.com/skyline75489/terminal/blob/66ce9e2917aa2fb81cf3bbf6613f3a15e643b87e/src/cascadia/TerminalCore/TerminalDispatch.cpp#L486
@TravisTX @floh96 I adjusted the sequence according to what's expected and yet still it doesn't work for V3. A bit puzzled here tbh.
But is it integrated in the latest windows terminal preview?
Even if I try manually with printf it does not work.
something like this should work printf "\e]9;9;C:\\\x9c"
@lnu fair point, I assumed so. Allow me to validate on ConEmu.
@JanDeDobbeleer maybe it has something to do with the config of your windows terminal like default starting folder or something like that
@lnu I feel a bit like an idiot as it should work in my latest PR according to the spec. I'll take a look tomorrow during my lunch break, maybe I made a silly mistake I just don't see now.
I got it working on the fix-path-notification
branch with either of these additional changes:
diff --git a/src/ansi_formats.go b/src/ansi_formats.go
index 0306d09..fb0e910 100644
--- a/src/ansi_formats.go
+++ b/src/ansi_formats.go
@@ -76,7 +76,7 @@ func (a *ansiFormats) init(shell string) {
a.escapeLeft = ""
a.escapeRight = ""
a.hyperlink = "\x1b]8;;%s\x1b\\%s\x1b]8;;\x1b\\"
- a.osc99 = "\x1b]9;9;\"%s\"\x9c"
+ a.osc99 = "\x1b]9;9;\"%s\"\x1b\\"
}
}
or
diff --git a/src/ansi_formats.go b/src/ansi_formats.go
index 0306d09..778251e 100644
--- a/src/ansi_formats.go
+++ b/src/ansi_formats.go
@@ -76,7 +76,7 @@ func (a *ansiFormats) init(shell string) {
a.escapeLeft = ""
a.escapeRight = ""
a.hyperlink = "\x1b]8;;%s\x1b\\%s\x1b]8;;\x1b\\"
- a.osc99 = "\x1b]9;9;\"%s\"\x9c"
+ a.osc99 = "\x1b]9;9;\"%s\"\x07"
}
}
I was looking at https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC:
Note. These codes may ends with ‘ESC\’ (two symbols - ESC and BackSlash) or ‘BELL’ (symbol with code \x07, same as ‘^a’ in *nix). For simplifying, endings in the following table marked as ‘ST’.
My understanding is that the sequence can either end in \x1b\\
(ie. \x1b\x5c
) or \x07
by itself.
You're right. With this it works printf "\e]9;9;d:\\dev\e\\"
which translates to \x1b]9;9d:\\dev\x1b\\
But somehow, it works when duplicating a tab but not when splitting.
I'll adjust, validate and merge! Thanks @chenxiaolong you made my day.
by the way, I've seen you named the template osc99. Maybe we should rename the hyperlink template to osc8.
Did anyone try with wsl. It crashes when duplicating on my side. I found this script while googling:https://gist.github.com/skyline75489/d655aede4c729eff178a1c0bfd10f622
@lnu did you go for the first or second sample @chenxiaolong provided? The link you shared is using the first variation.
The same as the hyperlink. Ending with \x1b\\
. The link comes from https://github.com/microsoft/terminal/issues/8166.
I also did some tests with the status indicator code osc 9;4 (https://github.com/microsoft/terminal/pull/8055). Would be cool to see the taskbar flashing when a long operation is running.
I confirm I'm not able to duplicate a wsl tab with the osc9;9 code emitted. Without it, the tab is duplicated correctly.
To make it work with wsl, we have to do the same as here:
_win_path=$(wslpath -m $(pwd))
printf "\033]9;9;%s\033\\" "$_win_path"
this code will correctly set the curent folder for wsl.
@lnu this still doesn't work for me in WT (have the preview), can you validate my branch so we can merge?
let me check this. In the meantime I'm adding a function on environment to detect wsl or not and transform the path accordingly.
@JanDeDobbeleer it works with your banch on my side. Just one question: why using x033 instead of x1b like for hyperlinks? Both works so maybe we can just keep the same for all osc sequences? I replace all 033 by x1b (also for title) and everything works.
Yes, I was under the impression you said it didn't work with that. As what I see is @chenxiaolong first sample now?
@JanDeDobbeleer Ok 033, x1b all the same :). so choose which one you want and you can use it for console, hyperlink and current folder. I tested both and it's ok. Sorry for the misunderstanding.
I'm adjusting it
let me check this. In the meantime I'm adding a function on environment to detect wsl or not and transform the path accordingly.
@lnu missed this one, in favour of merging your branch instead. Ping me on Twitter when done, I'm starting my day ;-)
Available in 3.39.1
@floh96 Can you confirm all is working now with version 3.89.1?
@lnu i will check after work
@lnu @JanDeDobbeleer it's working now in powershell and wsl thank you ❤️
@floh96 heads-up, I created a config switch for this at root level for the next version as enabling it by default effectively triggers a notification on iTerm2 😂
Sorry... just checked the doc of iterm2. The pandora box is opened: osc 9;9 not being standard across terminals, everyday will be a source of happiness 😅
Hey folks, this no longer seems to be working. I wonder if it's because instead of $(wslpath -m $(pwd))
it should now be just $PWD
.
Still working in pwsh but no more with wsl, checking why.
same as here https://github.com/JanDeDobbeleer/oh-my-posh/discussions/1508?
fixed here with https://github.com/JanDeDobbeleer/oh-my-posh/pull/1516
Is this what's causing my bash prompt to show this weird piece of code? (I've been searching everywhere for "9;9" and all I could find were binary matches in files, and this issue)
also, if I up then down (go to the previous command in history then back to clear line), it goes away.
oh yeah, I'm using sonicboom_light.omp.json
theme
@joaociocca yes. And depending on the terminal you might need to disable that in the config (theme) as bot all of them support it.
@JanDeDobbeleer pardon my noobness, how can I disable it in this case?
@joaociocca is that theme file on your file system? As there's a parameter in there osc99
which is set to true. Only needs to be removed or set to false.
@JanDeDobbeleer yes, I downloaded a copy of https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/sonicboom_light.omp.json
. Found the parameter, set to false and it's all pretty now! Thanks =D
This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.
It would be nice if the oh-my-posh v3 powershell module would support OSC 9;9. It was supported in v2. Windows Terminal added support for OSC 9;9 for the preview version (1.6) recently see https://github.com/microsoft/terminal/pull/8330 and https://github.com/microsoft/terminal/pull/8934.