mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
Add $fish_force_vi_cursor variable to allow cursor setting on unsupported terminals
This commit is contained in:
parent
a8e9f560e4
commit
f71737e58a
3 changed files with 48 additions and 43 deletions
|
@ -8,6 +8,7 @@
|
|||
- Ctrl-C no longer kills background jobs for which job control is disabled, matching POSIX semantics (#6828).
|
||||
- Improve Gradle completion
|
||||
- Fixed `pushd`'s behavior with respect to the directory stack when given an invalid argument
|
||||
- A new variable, `$fish_vi_force_cursor`, has been added. This can be set to force `fish_vi_cursor` to attempt changing the cursor shape in vi mode, regardless of terminal. Additionally, the `fish_vi_cursor` option `--force-iterm` has been deprecated; all usages can be replaced by setting `$fish_vi_force_cursor`.
|
||||
- The history file is now created with user-private permissions, matching other shells (#6926). The directory containing the history file remains private, so there should not have been any private date revealed.
|
||||
|
||||
### Syntax changes and new commands
|
||||
|
|
|
@ -1410,6 +1410,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.
|
||||
|
||||
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:
|
||||
|
||||
Command mode
|
||||
|
|
|
@ -10,52 +10,55 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
|||
return
|
||||
end
|
||||
|
||||
# Emacs Makes All Cursors Suck
|
||||
if set -q INSIDE_EMACS
|
||||
return
|
||||
end
|
||||
# If this variable is set, skip all checks
|
||||
if not set -q fish_vi_force_cursor
|
||||
|
||||
# vte-based terms set $TERM = xterm*, but only gained support in 2015.
|
||||
# From https://bugzilla.gnome.org/show_bug.cgi?id=720821, it appears it was version 0.40.0
|
||||
if set -q VTE_VERSION
|
||||
and test "$VTE_VERSION" -lt 4000 2>/dev/null
|
||||
return
|
||||
end
|
||||
# Emacs Makes All Cursors Suck
|
||||
if set -q INSIDE_EMACS
|
||||
return
|
||||
end
|
||||
|
||||
# Similarly, genuine XTerm can do it since v280.
|
||||
if set -q XTERM_VERSION
|
||||
and not test (string replace -r "XTerm\((\d+)\)" '$1' -- "$XTERM_VERSION") -ge 280 2>/dev/null
|
||||
return
|
||||
end
|
||||
# vte-based terms set $TERM = xterm*, but only gained support in 2015.
|
||||
# From https://bugzilla.gnome.org/show_bug.cgi?id=720821, it appears it was version 0.40.0
|
||||
if set -q VTE_VERSION
|
||||
and test "$VTE_VERSION" -lt 4000 2>/dev/null
|
||||
return
|
||||
end
|
||||
|
||||
# We need one of these terms.
|
||||
# It would be lovely if we could rely on terminfo, but:
|
||||
# - The "Ss" entry isn't a thing in macOS' old and crusty terminfo
|
||||
# - It is set for xterm, and everyone and their dog claims to be xterm
|
||||
#
|
||||
# So we just don't care about $TERM, unless it is one of the few terminals that actually have their own entry.
|
||||
#
|
||||
# Note: Previous versions also checked $TMUX, and made sure that then $TERM was screen* or tmux*.
|
||||
# We don't care, since we *cannot* handle term-in-a-terms 100% correctly.
|
||||
if not set -q KONSOLE_PROFILE_NAME
|
||||
and not test -n "$KONSOLE_VERSION" -a "$KONSOLE_VERSION" -ge "200400" # konsole, but new.
|
||||
and not set -q ITERM_PROFILE
|
||||
and not set -q VTE_VERSION # which version is already checked above
|
||||
and not set -q XTERM_VERSION
|
||||
and not string match -rq '^st(-.*)$' -- $TERM
|
||||
and not string match -q 'xterm-kitty*' -- $TERM
|
||||
and not string match -q 'rxvt*' -- $TERM
|
||||
and not string match -q 'alacritty*' -- $TERM
|
||||
return
|
||||
end
|
||||
# Similarly, genuine XTerm can do it since v280.
|
||||
if set -q XTERM_VERSION
|
||||
and not test (string replace -r "XTerm\((\d+)\)" '$1' -- "$XTERM_VERSION") -ge 280 2>/dev/null
|
||||
return
|
||||
end
|
||||
|
||||
# HACK: Explicitly disable on ITERM because of #3696, which is weirdness with multi-line prompts.
|
||||
# We allow an explicit "--force-iterm" as first argument to skip this.
|
||||
# It's recommended only if you don't use a multi-line prompt.
|
||||
if contains -- $argv[1] --force-iterm
|
||||
set -e argv[1]
|
||||
else if set -q ITERM_PROFILE
|
||||
return
|
||||
# We need one of these terms.
|
||||
# It would be lovely if we could rely on terminfo, but:
|
||||
# - The "Ss" entry isn't a thing in macOS' old and crusty terminfo
|
||||
# - It is set for xterm, and everyone and their dog claims to be xterm
|
||||
#
|
||||
# So we just don't care about $TERM, unless it is one of the few terminals that actually have their own entry.
|
||||
#
|
||||
# Note: Previous versions also checked $TMUX, and made sure that then $TERM was screen* or tmux*.
|
||||
# We don't care, since we *cannot* handle term-in-a-terms 100% correctly.
|
||||
if not set -q KONSOLE_PROFILE_NAME
|
||||
and not test -n "$KONSOLE_VERSION" -a "$KONSOLE_VERSION" -ge "200400" # konsole, but new.
|
||||
and not set -q ITERM_PROFILE
|
||||
and not set -q VTE_VERSION # which version is already checked above
|
||||
and not set -q XTERM_VERSION
|
||||
and not string match -rq '^st(-.*)$' -- $TERM
|
||||
and not string match -q 'xterm-kitty*' -- $TERM
|
||||
and not string match -q 'rxvt*' -- $TERM
|
||||
and not string match -q 'alacritty*' -- $TERM
|
||||
return
|
||||
end
|
||||
|
||||
# HACK: Explicitly disable on ITERM because of #3696, which is weirdness with multi-line prompts.
|
||||
# --force-iterm is now deprecated; set $fish_vi_force_cursor instead
|
||||
if contains -- $argv[1] --force-iterm
|
||||
set -e argv[1]
|
||||
else if set -q ITERM_PROFILE
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
set -l terminal $argv[1]
|
||||
|
@ -114,4 +117,3 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
|
|||
end
|
||||
" | source
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue