From e45bddcbb1b9c42cf0694880fbb347aaf9775573 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Fri, 31 Mar 2023 20:03:24 +0200 Subject: [PATCH] __fish_cursor_xterm: Ignore unknown cursor settings This prevents leaking the escape sequence by printing nonsense, and it also allows disabling cursor setting by just setting the variable to e.g. empty. And if we ever added any shapes, it would allow them to be used on new fish and ignored on old Fixes #9698 --- doc_src/interactive.rst | 2 ++ share/functions/__fish_cursor_xterm.fish | 3 +++ 2 files changed, 5 insertions(+) diff --git a/doc_src/interactive.rst b/doc_src/interactive.rst index aaddd2cfd..42a6563d3 100644 --- a/doc_src/interactive.rst +++ b/doc_src/interactive.rst @@ -429,6 +429,8 @@ The ``fish_vi_cursor`` function will be used to change the cursor's shape depend Additionally, ``blink`` can be added after each of the cursor shape parameters to set a blinking cursor in the specified shape. +Fish knows the shapes "block", "line" and "underscore", other values will be ignored. + If the cursor shape does not appear to be changing after setting the above variables, it's likely your terminal emulator does not support the capabilities necessary to do this. It may also be the case, however, that ``fish_vi_cursor`` has not detected your terminal's features correctly (for example, if you are using ``tmux``). If this is the case, you can force ``fish_vi_cursor`` to set the cursor shape by setting ``$fish_vi_force_cursor`` in ``config.fish``. You'll have to restart fish for any changes to take effect. If cursor shape setting remains broken after this, it's almost certainly an issue with your terminal emulator, and not fish. .. _vi-mode-command: diff --git a/share/functions/__fish_cursor_xterm.fish b/share/functions/__fish_cursor_xterm.fish index 7a964ba99..e05a1b9a5 100644 --- a/share/functions/__fish_cursor_xterm.fish +++ b/share/functions/__fish_cursor_xterm.fish @@ -8,6 +8,9 @@ function __fish_cursor_xterm -d 'Set cursor (xterm)' set shape 4 case line set shape 6 + case '*' + # Unknown shape + return end if contains blink $argv set shape (math $shape - 1)