Skip to content

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

Closed

Description

@timbertson

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".

Activity

  1. timbertson commented on Jul 15, 2013

    @timbertson
    ContributorAuthor

    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
    
  2. sugar700 commented on Jul 18, 2013

    @sugar700
    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.

  3. timbertson commented on Jul 18, 2013

    @timbertson
    ContributorAuthor

    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?

  4. sugar700 commented on Jul 18, 2013

    @sugar700
    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.

  5. sugar700 commented on Sep 4, 2013

    @sugar700
    Contributor

    Fixed by #973. Closing.

  6. strelec commented on Nov 17, 2014

    @strelec

    Doesn't seem to work anymore.

  7. ridiculousfish commented on Nov 17, 2014

    @ridiculousfish
    Member

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

  8. locked as resolved and limited conversation to collaborators on Apr 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions