Previously we'd return the Url string. Now we provide a Url object that provides access to the various elements of the Url. This will cause slightly breakage for folks that were treating it as a string in their status event handlers, for example. The docs have been updated to show how to run with both this new Url object and also continue to run on older versions of wezterm. They now also show how to manually percent decode the url for older versions of wezterm. refs: https://github.com/wez/wezterm/discussions/4157 refs: https://github.com/wez/wezterm/issues/4000
1.4 KiB
pane:get_current_working_dir()
{{since('20201031-154415-9614e117')}}
Returns the current working directory of the pane, if known. The current directory can be specified by an application sending OSC 7.
If OSC 7 was never sent to a pane, and the pane represents a locally spawned process, then wezterm will:
- On Unix systems, determie the process group leader attached to the PTY
- On Windows systems, use heuristics to infer an equivalent to the foreground process
With the process identified, wezterm will then try to determine the current working directory using operating system dependent code:
| OS | Supported? |
|---|---|
| macOS | Yes, {{since('20201031-154415-9614e117', inline=True)}} |
| Linux | Yes, {{since('20201031-154415-9614e117', inline=True)}} |
| Windows | Yes, {{since('20220101-133340-7edc5b5a', inline=True)}} |
If the current working directory is not known then this method returns nil.
Otherwise, it returns the current working directory as a URI string.
Note that while the current working directory is usually a file path, it is possible for an application to set it to an FTP URL or some other kind of URL, which is why this method doesn't simply return a file path string.
{{since('nightly')}}
This method now returns a Url object which provides a convenient way to decode and operate on the URL.