From acc2353328e97e6e0ff7dfd8d6310e590ed3eb3b Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Fri, 18 Nov 2016 19:17:23 +0100 Subject: [PATCH] vi_cursor: For TERM = xterm require another condition We cannot just use TERM = xterm and defined Ss sequence, as some old vte-based terminals are still in the wild that don't support the sequence and don't have $VTE_VERSION set. I have tested this on - konsole - supported and works ($KONSOLE_PROFILE_NAME) - new xterm - supported and works ($XTERM_VERSION) - lxterminal-gtk3 - supported and works ($VTE_VERSION) - new gnome-terminal - supported and works ($VTE_VERSION) - lxterminal-gtk2 - not supported and deactivated (no $VTE_VERSION) - tmux in konsole - works - tmux in lxterminal-gtk2 - deactivated and for all supported ones with the respective variable erased, to see that it is deactivated. Fixes #3499. --- share/functions/fish_vi_cursor.fish | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/share/functions/fish_vi_cursor.fish b/share/functions/fish_vi_cursor.fish index 0dcadd1f6..63951b8c3 100644 --- a/share/functions/fish_vi_cursor.fish +++ b/share/functions/fish_vi_cursor.fish @@ -24,6 +24,7 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes' and begin set -q KONSOLE_PROFILE_NAME or set -q ITERM_PROFILE or test "$VTE_VERSION" -ge 4000 + or test (string replace -r "XTerm\((\d+)\)" '$1' -- $XTERM_VERSION) -ge 280 end # .. unless an unsupporting terminal has been started in tmux inside a supporting one and begin string match -q "screen*" -- $TERM @@ -39,6 +40,21 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes' and test "$VTE_VERSION" -lt 4000 end or set -q INSIDE_EMACS + or begin + # TERM = xterm is special because plenty of things claim to be it, but aren't fully compatible + # This includes old vte-terms (without $VTE_VERSION), old xterms (without $XTERM_VERSION or < 280) + # and maybe other stuff. + # This needs to be kept _at least_ as long as Ubuntu 14.04 is still a thing + # because that ships a gnome-terminal without support and without $VTE_VERSION. + string match -q 'xterm*' -- $TERM + and not begin set -q KONSOLE_PROFILE_NAME + or set -q ITERM_PROFILE + or test "$VTE_VERSION" -ge 4000 + # If $XTERM_VERSION is undefined, this will return 1 and print an error. Silence it. + or test (string replace -r "XTerm\((\d+)\)" '$1' -- $XTERM_VERSION) -ge 280 ^/dev/null + end + end + return end