From ba9c38759056cc70e883360fc844b78571c700f6 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Fri, 14 Dec 2018 04:46:14 -0800 Subject: [PATCH] __fish_config_interactive: tighten up checks for OSC 7 feature I spent some time figuring out $TERM_PROGRAM_VERSION and Terminal.app's capabilities over time. [1] Only use OSC 7 if running on the version of Terminal.app that added it or newer. In the past this would have been harder because `test` couldn't do float comparisons. cleanup: Don't bother setting a local $TERM_PROGRAM if it's unset: quoting is enough to keep test happy. For the version numbers, 0"$var" is safe against unset variables for numerical comparisons. [1]: https://github.com/fish-shell/fish-shell/wiki/Terminal.app-characteristics --- share/functions/__fish_config_interactive.fish | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 209cdd1ca..0b2fc8063 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -271,18 +271,14 @@ function __fish_config_interactive -d "Initializations that should be performed end # Notify terminals when $PWD changes (issue #906). - # VTE based terminals, Terminal.app, and iTerm.app support this. - set -q VTE_VERSION - or set -l VTE_VERSION 0 - set -q TERM_PROGRAM - or set -l TERM_PROGRAM - if test "$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" + # VTE based terminals, Terminal.app , and iTerm.app support this. + if test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = "Apple_Terminal" -a 0"$TERM_PROGRAM_VERSION" -ge 309 function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes' if status --is-command-substitution or set -q INSIDE_EMACS return end - printf \e\]7\;file://\%s\%s\a $hostname (string escape --style=url $PWD) + printf \e\]7\;file://%s%s\a $hostname (string escape --style=url $PWD) end __update_cwd_osc # Run once because we might have already inherited a PWD from an old tab end