OS X 10.11 adds a nice feature to Terminal.app that interprets control sequences of the form
ESC ] 6 ; file://hostname/<path-as-URL> BEL
as specifying the "document" which is currently being edited or viewed. As an example, entering
echo -e "\x1b]6;file://localhost/etc/passwd\a"
will cause the terminal title to display the filename passwd
, which can be cmd+clicked on to get a breadcrumb trail (a feature of the "document title" in most file editors on OS X). The OS X default bashrc
already uses this sequence to insert the current working directory into the window title.
I'd like to know how I can get Vim to output this particular escape sequence whenever it edits a new file (and, ideally, how to unset it once the editing stops - e.g. on quit or file change). Extensions to e.g. less
and other programs would also be very helpful.
Although the URL technically has to be properly URL-encoded, I'm totally fine if it isn't - I don't usually edit files with particularly unusual filenames in Vim.