Comment 36 for bug 1030562

Revision history for this message
Egmont Koblinger (egmont-gmail) wrote :

The return value of get_current_directory_uri can be modified by emitting the OSC 7 escape sequence inside the terminal, e.g.:

echo -ne '\e]7;file://foo/usr/bin\a'

The return value is None until this escape sequence is first encountered.

Vte ships an /etc/profile.d/vte.sh which should be sourced at shell startup. This hooks up to the shell so that each time the prompt is printed, this escape sequence is emitted, notifying vte about the current directory. Ideally, this is done by every distribution, and should be done by you too.

Take a look at gnome-terminal's source, src/terminal-screen.c, terminal_screen_get_current_dir(). (No C knowledge is required to understand.)

It first calls get_current_directory_uri(), and if succeeds (that is, such escape sequence has been printed), it uses that value (stripping off the file: prefix, unescaping etc.).

If it returns null, that is, such escape sequence has not been seen in the terminal yet, then it uses the value that gnome-terminal internally remembers which is the initial working directory of the given tab.