From 348a5b6bafcd0df2194d4c380a03f6b1bb8ae1f2 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sun, 30 Jan 2022 19:19:43 +0100 Subject: [PATCH] Restyle detection of terminals that support OSC 7 We detect one terminal (foot) with a "string match" command, and all others in a long "test" command. Let's put the detection of each terminal on a new line. This should be easier to read and change. It also allows to lose one level of indentation. --- .../functions/__fish_config_interactive.fish | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/share/functions/__fish_config_interactive.fish b/share/functions/__fish_config_interactive.fish index 162e15045..64cb7b41a 100644 --- a/share/functions/__fish_config_interactive.fish +++ b/share/functions/__fish_config_interactive.fish @@ -257,16 +257,19 @@ function __fish_config_interactive -d "Initializations that should be performed # Notify terminals when $PWD changes (issue #906). # VTE based terminals, Terminal.app, iTerm.app (TODO), and foot support this. if not set -q FISH_UNIT_TESTS_RUNNING - if string match -q -- 'foot*' $TERM - or test 0"$VTE_VERSION" -ge 3405 -o "$TERM_PROGRAM" = Apple_Terminal -a (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309 -o "$TERM_PROGRAM" = WezTerm - function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes' - if status --is-command-substitution || set -q INSIDE_EMACS - return - end - 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 + and begin + string match -q -- 'foot*' $TERM + or test 0"$VTE_VERSION" -ge 3405 + or test "$TERM_PROGRAM" = Apple_Terminal && test (string match -r '\d+' 0"$TERM_PROGRAM_VERSION") -ge 309 + or test "$TERM_PROGRAM" = WezTerm end + function __update_cwd_osc --on-variable PWD --description 'Notify capable terminals when $PWD changes' + if status --is-command-substitution || set -q INSIDE_EMACS + return + end + 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 # Create empty configuration directores if they do not already exist