-
-
Notifications
You must be signed in to change notification settings - Fork 862
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
document how to use OSC 7 on Windows #146
Comments
That feature requires that the shell (or some other application) emit an escape sequence each time it changes the current directory. That is in the default for bash and zsh on the Fedora system that jsgf used when building that feature, and I have a slightly different version of that in my personal shell setup. While the escape sequence should logically be emitted when the working directory changes, the typical approach is to have the shell emit it just before it prints the prompt. The same technique should work on windows, but you'll need to translate it to your shell; I don't think that is possible with CMD, but it should be possible with powershell. For CMD, you might be wizard enough to cook up an alias or something that emits the escape sequence when you run I've attached the shell snippet from Fedora to this comment which includes more shell integration than just the current directory stuff, as well as some escaping. The gist of the escape sequence is:
If you come up with something that works for this for CMD and/or powershell, I've love to include it in the wezterm docs! |
re: why not look at handles? cmd.exe may be running eg: msys bash. How do you know which is the right process to snoop? How do you know which is the right handle to look at? What if you are actually sshing into a remote windows system where you don't have access to inspect the process? The spec for this feature: https://gitlab.freedesktop.org/terminal-wg/specifications/merge_requests/7/diffs touches briefly on this. |
The right one would be a child process of wezterm.exe, yes? |
it's really not that simple: as I said above, the direct child may be running an arbitrary tree of nested children: a cmd may run a cmd which may run a cmd which may run a bash shell. There is no "right" way to pick one, and even if there was, that isn't portable and doesn't fit how ptys and ttys work; there may not even be a child process: we may be running a serial connection to a linux machine for instance, or a TLS connection to a remote multiplexer. The feature that is implemented works based on an escape sequence because that is the most reasonable way to implement this specification; that's why it is specified in the way that it is. |
That's a shame, I don't think there's any way of throwing the escape sequence in a way that wouldn't cause a new line, unless there's some magic way of doing it with doskey. |
I took a peek at some information for CMD and in theory using this feature should be as simple as:
|
This allows this prompt setting to work: ``` prompt $E]7;file://localhost/$P$E\$P$G ``` although this one sets it for future prompts: ``` setx prompt $E]7;file://localhost/$P$E\$P$G ``` refs: #146
Turns out that I overlooked something; the pty was actually passing through the sequence, but we weren't passing the cwd through to the newly spawned processes. I've pushed a commit that enables this feature for windows; you just need to run:
to set it up in the default environment for you when you next login, so that it applies to all of your cmd windows by default. |
In the interest of portable compatibility, is there any way I can have wezterm auto-execute this for cmd windows? |
This is useful for setting up a reasonable initial environment. For example, on Windows you might want to set the `prompt` environment so that some basic shell integration is enabled; this will cause new tabs to open with the same cwd as the current tab: ``` set_environment_variables = { "prompt"="$E]7;file://localhost/$P$E\\$P$G" } ``` This setting is intended to apply only to the local domain. refs: #146
With the commit that I just pushed, put this in your set_environment_variables = { "prompt"="$E]7;file://localhost/$P$E\\$P$G" } |
You can get a little more fancy; this shows an alternative way to express setting this environment, and also how to embed some SGR sequences to change the color and have the prompt span multiple lines: [set_environment_variables]
prompt = "$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m " |
This comment has been minimized.
This comment has been minimized.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
As described in #114, I should be able to open wezterm, navigate up a directory
cd ..
, and then press the plus button to open a new tab, which should open a new cmd inC:\Users
, but instead I get my defaultC:\Users\{Username}
directory.This might not be limited to Windows.
The text was updated successfully, but these errors were encountered: