-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Consider using OSC 9;9 to inform Windows Terminal about CWD #8166
Comments
CC @Maximus5 for any suggestions on the remote connections. |
I owe you a longer writeup on both this and OSC 7, and now that I'm back from leave, I don't really have any excuses 😝 I'll try to write something up later today. Thanks for your patience! |
@zadjii-msft It's absolutely OK. Take you time, man. I've been experimenting with ConEmu and OSC 9;9 sequences. From what I can tell, the result of a OSC 9;9 is an option in the "Startup directory" when creating a new console: So yeah, I guess we could use it for #3158 without breaking the original meaning of the this sequence. |
(copypasta from my comment in #7668) This one doesn't seem that bad. Since it's a windows-first sequence, it doesn't need to know anything else about who's emitting the path. We can always assume it has been emitted as a Windows path. On the surface, this seems to work great, save for one scenario - ssh. This sequence doesn't accept any sort of I think I'm okay with us implementing this as-is for the time being though. It's not a perfect sequence, but it's good enough, and doesn't come with the compat baggage that |
I think as a very Win32 specific sequence, I can understand why HOSTNAME does not exist in OSC 9;9: sshing into Win32 machines is simply not possible at the time the sequence was invented. And WSL was also not a thing.
Note that for most cases, it’s still good enough. We’ll always check the availability of the CWD before passing it to shell program, to make sure it actually exists on the local machine.
Having a working but not perfect solution is better than have nothing at all. Besides we can always extent OSC 9;9 as long as we align the movement with ConEmu in the future.
获取 Outlook for iOS<https://aka.ms/o0ukef>
|
Just a couple of things to mention. From ConEmu perspective. The "cwd" could be unix encoded (/mnt/c/path, /cyddrive/c/path, or simply /c/path) or Windows encoded (c:\path). And there are also network paths too... Depends on the shell emitting the sequence and settings. It does not have much sense to check path existence upfront, we could have e.g. /c/users/admin on remote and localhost both. In ConEmu the cwd is used not only for starting new shell, but also for processing "hyperlinks", such as produced in compilers errors output. ConEmu uses cwd to expand relative path. Interesting point here is that we could have in backscroll different points where cwd was changed (make was started from different folders). So it could be helpful if Terminal saves cwd for range of lines. |
Apart from the path format (file:// URL vs potentially DOS-style path) and not having a 'hostname', what's the difference between this and OSC 7? Both notify of CWD, as I understand. Is the advantage simply that we know a Windows-unaware program isn't going to generate this? And hence that if one needs to use Although ConEmu docs mentioned in the original ticket just send the locally-visible path out of WSL/Cygwin to OSC 9;9... It's not clear how that can work, perhaps it relies on something in the ConEmu cygwin/msys terminal connector, which means that OSC 7 and OSC 9;9 remain semantically the same, and WSL/Cygwin are still problematic. |
I'm not sure when OSC7 appeared. The VT100 and xterm sequences does not have this code, and these standards I generally took into account implementing ConEmu parser. Connector is not required to process the OSC9;9, ConEmu does not care who actually emits the cwd to terminal. On the other hand, without connector no ANSI is written to console, they are processed by cygwin1.dll. But Terminal should not care about it I believe. If sequence is emitted, terminal should note the cwd change. |
Yeah, XTerm doesn't support |
To be clear, I wasn't trying to be critical of ConEmu for ignoring an existing standard etc. What I'm really wondering is that given the ConEmu documentation suggests this for
and I had expected to find it using something like:
|
@Maximus5 Thanks for the reply. One thing I'd like to point out is that, we are mainly targeting #3158 as the primary usage of OSC 9;9.
Generally I get your point. But as I said we will mainly use the CWD to open new terminal tab in same directory. We don't really have an dialog to choose the starting directory, at least for now. In my initial implementation, the newly spawned shell will just arbitrarily use the CWD set by previous shells. This is why we want the CWD to be a valid local path (also why we take remote connections into consideration). @TBBle The screenshot in my previous comment somewhat explains how it works. As far as I can see, ConEmu will not enforce users to use CWD to open new tabs. Instead it just adds an option in the dropdown. I guess this is one of the reasons why ConEmu is spared from the issues discussed in #7668. |
Ah, thank you, I understand now. I hadn't realised "Create New Console" mentioned in the ConEmu docs had an intervening dialog before actually launching a new console. |
I'd certainly be curious how that's supposed to work as well. I presumed that this was only being used for emit Windows-style paths for ConEmu. I'm okay with supporting this sequence, but only with the caveat "these paths must be the Windows relative path". If this isn't the typical usage, then it's certainly no better than Forcing the emitter to use Windows root-relative paths definitely puts the onus on the emitter to ensure that they're self-aware if they're running in WSL, cygwin, etc. It's not great, but for now it's better than OSC7 where the precedent has already been set that the emitter won't be aware of such scenarios. As far as path validation goes, I'd start by treating this the same way |
That's almost true. User may configure task to use
ConEmu can (at least should) do automatic translation of Unix path to Windows path to maintain PWD. But with |
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR implement the OSC 9;9 |Sequence|Descriptoin| | :------------- | :----------: | |ESC ] 9 ; 9 ; “cwd” ST | Inform ConEmu about shell current working directory.| <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References #8214 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes #8166 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request This PR implement the OSC 9;9 |Sequence|Descriptoin| | :------------- | :----------: | |ESC ] 9 ; 9 ; “cwd” ST | Inform ConEmu about shell current working directory.| <!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> ## References microsoft#8214 <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [X] Closes microsoft#8166 * [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Documentation updated. If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/terminal) and link it here: #xxx * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx <!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed
Has anyone managed to make it work for cmd? I was using pwsh with osc9;9 string, but pwsh was too slow for normal use and am thinking of using cmd for interactive use. But I cannot set it up to open the new tab/split in current directory. Help. |
https://gist.github.com/LuanVSO/09ba0239fe7c1a959a9b07c7156c5e13 from #3158 (comment) might work. (I haven't tried it) |
Yes, it works. The one I got before used OSC7 instead of |
Yeah, |
EDIT: Found a solution: I'm using Git Bash as default terminal in Window Terminal. Already tried unsuccessful:
when terminal reopens it shows that error:
|
Description of the new feature/enhancement
About a month ago I've filed #7668 , in the seek of a solution for #3158 . It raised a lot of discussion and I can totally understand why #7668 is acceptable to some people but unpalatable to others.
Recently with #8055 being accepted as a solution, I thought why not accept more sequences from ConEmu, which is a fantastic product I've personally used for a long time. So here I purpose we implement another OSC 9 custom sequence from ConEmu:
The source can be found in the ConEmu doc.
Proposed technical implementation details (optional)
PR: #8330
Shell configurations:
The text was updated successfully, but these errors were encountered: