-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
Emit OSC-7 escape when changing directory #1147
Comments
The code should go here: Line 6503 in c974690 Please share the exact printf() OR raise a PR. I don't own macOS so I can't test it. |
Thanks! I'll see what I can do about opening a PR.
FWIW you don't need macOS. It's also supported by libvte, and while I don't know if all VTE-based terminals therefore automatically support it, gnome-terminal should (not asking you to implement it though - just an FYI). |
I am on Xubuntu and tried with xfce4-terminal and it didn't work somehow. Can't really spend time on something that someone else already knows how to implement and test easily. |
* Signal CWD change to terminal via OSC-7 Closes #1147 * Make OSC-7 emission gated by NOX11 * Use newpath variable in gethostname()
* Signal CWD change to terminal via OSC-7 Closes #1147 * Make OSC-7 emission gated by NOX11 * Use newpath variable in gethostname() Use dynamic memory for hostname
Originally reported here: https://codeberg.org/dnkl/foot/issues/696; some users expect the terminal's builtin "spawn a new window" feature to open the new terminal window in nnn's current directory.
This works "automagically" on some terminals (which most likely dig through
/proc
to find out the current CWD of the leaf child process).Others implement OSC-7, and escape that let's the application control which directory the terminal should consider to be the "current" one. Shells are often configured to emit this as part of rendering their prompts.
OSC-7 is pretty simple; just URL encode the directory and write
\033]7;file://$HOSTNAME$CWD\033\\
(for example,\033]7;file://mini.la.casa/home/user/foobar\033\\
). See e.g. https://codeberg.org/dnkl/foot/wiki#user-content-how-to-configure-my-shell-to-emit-the-osc-7-escape-sequence for a shell implementation. It is also documented here: https://iterm2.com/documentation-escape- codes.html.It is implemented by at least VTE terminals, iTerm2 and foot.
Note that well behaving terminals ignore unrecognized OSC sequences, meaning it should be safe to emit OSC-7 unconditionally.
Note: avoid using
localhost
as hostname. The terminal matches the hostname to be able to ignore OSC-7 escapes from remote hosts (e.g. SSH).Is it a "standardized" escape? It's not a VT escape, and not part of ECMA-48. So no, in that sense it's not standardized. There's an open issue over at terminal-wg, and one unmerged PR (unmerged due to too much bikeshedding). With that, I fully understand if this is a feature you want to pass :)
The text was updated successfully, but these errors were encountered: