fish doesn't notify gnome terminal / vte of current directory #906

Closed
timbertson opened this Issue Jul 8, 2013 · 7 comments

Comments

Projects
None yet
4 participants
@timbertson
Contributor

timbertson commented Jul 8, 2013

Fedora 19 includes the latest gnome-terminal, which (when using fish as your shell) no longer opens new tabs in the same cwd as the current tab.

This seems to be due to this change in vte: https://bugzilla.gnome.org/show_bug.cgi?id=675987

Fedora 19 includes a /etc/profile.d/vte.sh for bash / zsh, which does:

printf "\033]7;file://%s%s\a" "${HOSTNAME:-}" "$(__vte_urlencode "${PWD}")"

as part of PS1.

I tried (in fish) manually running:

printf "\033]7;file:///home/tim/dev/python\a"

Which does cause the next window to open in ~/dev/python, so it should just be a matter of adding something similar to fish when it's running under vte.

For reference, the script distributed with fedora adds these hooks if $VTE_VERSION is present and greater or equal to "3405".

@timbertson

This comment has been minimized.

Show comment
Hide comment
@timbertson

timbertson Jul 15, 2013

Contributor

Here's a workaround I've added to my own config.fish. The perl stuff is ugly, but I couldn't find a quicker way of urlencoding a string - perhaps there's already something built into fish that can do it?

if begin set -q VTE_VERSION; and test $VTE_VERSION -ge 3405; end
    function __update_vte_cwd --on-variable PWD --description 'Notify VTE of change to $PWD'
        status --is-command-substitution; and return
        perl -MURI::Escape -MEnv -e 'print "\033]7;file://" . uri_escape($PWD, "^a-za-z0-9\-\._~\/") . "\a"'
    end
end
Contributor

timbertson commented Jul 15, 2013

Here's a workaround I've added to my own config.fish. The perl stuff is ugly, but I couldn't find a quicker way of urlencoding a string - perhaps there's already something built into fish that can do it?

if begin set -q VTE_VERSION; and test $VTE_VERSION -ge 3405; end
    function __update_vte_cwd --on-variable PWD --description 'Notify VTE of change to $PWD'
        status --is-command-substitution; and return
        perl -MURI::Escape -MEnv -e 'print "\033]7;file://" . uri_escape($PWD, "^a-za-z0-9\-\._~\/") . "\a"'
    end
end
@xfix

This comment has been minimized.

Show comment
Hide comment
@xfix

xfix Jul 18, 2013

Member

The workaround, while works, it's also wrong (to implement in the shell itself, that is). I'm even going to ignore perl dependency - URI::Escape isn't core Perl module, so while it's possible (but I rather wouldn't) to add perl to dependencies (it's rather common), I wouldn't depend on modules that aren't in the core (see corelist).

I would rather see a solution that wouldn't run unneeded processes every time the path is changed, considering path changes are rather common. But, I'm not sure whatever it's even possible. At least, thanks for noting that it's easy to detect gnome-terminal's version (or rather, vte used by it) without external processes.

Member

xfix commented Jul 18, 2013

The workaround, while works, it's also wrong (to implement in the shell itself, that is). I'm even going to ignore perl dependency - URI::Escape isn't core Perl module, so while it's possible (but I rather wouldn't) to add perl to dependencies (it's rather common), I wouldn't depend on modules that aren't in the core (see corelist).

I would rather see a solution that wouldn't run unneeded processes every time the path is changed, considering path changes are rather common. But, I'm not sure whatever it's even possible. At least, thanks for noting that it's easy to detect gnome-terminal's version (or rather, vte used by it) without external processes.

@timbertson

This comment has been minimized.

Show comment
Hide comment
@timbertson

timbertson Jul 18, 2013

Contributor

Yeah, I am assuming (hoping?) that fish internals have access to a URL encoding function somewhere - I wasn't actually suggesting adding perl as a dependency. This would also cut out the subprocess (assuming printf is implemented in-process).

It's checking for >= 0.34.5 (it uses -ge), isn't that correct if the change happened in vte 0.34.5? Or are you saying that the functionality was added in 0.34.5, and something else to do with bash changed in 0.34.5?

Contributor

timbertson commented Jul 18, 2013

Yeah, I am assuming (hoping?) that fish internals have access to a URL encoding function somewhere - I wasn't actually suggesting adding perl as a dependency. This would also cut out the subprocess (assuming printf is implemented in-process).

It's checking for >= 0.34.5 (it uses -ge), isn't that correct if the change happened in vte 0.34.5? Or are you saying that the functionality was added in 0.34.5, and something else to do with bash changed in 0.34.5?

@xfix

This comment has been minimized.

Show comment
Hide comment
@xfix

xfix Jul 18, 2013

Member

Oh, sorry, I was confused. 0.34.5 is fine (it happens). Also, yes, printf is a builtin. It would be nice if fish would have some builtin way of iterating in strings (something like ${a:0:1} in bash, or $a[1] in zsh), so it would be possible to do it inside fish.

Of course, there is always an option of making internal builtin, but... I'm not sure if I like it.

Member

xfix commented Jul 18, 2013

Oh, sorry, I was confused. 0.34.5 is fine (it happens). Also, yes, printf is a builtin. It would be nice if fish would have some builtin way of iterating in strings (something like ${a:0:1} in bash, or $a[1] in zsh), so it would be possible to do it inside fish.

Of course, there is always an option of making internal builtin, but... I'm not sure if I like it.

@xfix

This comment has been minimized.

Show comment
Hide comment
@xfix

xfix Sep 4, 2013

Member

Fixed by #973. Closing.

Member

xfix commented Sep 4, 2013

Fixed by #973. Closing.

@xfix xfix closed this Sep 4, 2013

@strelec

This comment has been minimized.

Show comment
Hide comment
@strelec

strelec Nov 17, 2014

Doesn't seem to work anymore.

strelec commented Nov 17, 2014

Doesn't seem to work anymore.

@ridiculousfish

This comment has been minimized.

Show comment
Hide comment
@ridiculousfish

ridiculousfish Nov 17, 2014

Member

I filed #1814 to track the investigation. strelec, please share any information you have there.

Member

ridiculousfish commented Nov 17, 2014

I filed #1814 to track the investigation. strelec, please share any information you have there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment