Skip to content
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

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

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

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

timbertson opened this issue Jul 8, 2013 · 7 comments
Milestone

Comments

@timbertson
Copy link
Contributor

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
Copy link
Contributor Author

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

@KamilaBorowska
Copy link
Contributor

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
Copy link
Contributor Author

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?

@KamilaBorowska
Copy link
Contributor

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.

@KamilaBorowska
Copy link
Contributor

Fixed by #973. Closing.

@strelec
Copy link

strelec commented Nov 17, 2014

Doesn't seem to work anymore.

@ridiculousfish
Copy link
Member

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants