Redraw vi cursor if tmux pane focus changes

Fixes #4788.
This commit is contained in:
Fabian Homborg 2018-03-07 11:06:23 +01:00
parent 1cad15b01f
commit a0fbb8dea7
4 changed files with 25 additions and 6 deletions

View file

@ -234,6 +234,20 @@ function __fish_config_interactive -d "Initializations that should be performed
__fish_enable_bracketed_paste
end
# Similarly, enable TMUX's focus reporting when in tmux.
# This will be handled by
# - The keybindings (reading the sequence and triggering an event)
# - Any listeners (like the vi-cursor)
if set -q TMUX
function __fish_enable_focus --on-event fish_postexec
echo \e\[\?1004h
end
function __fish_disable_focus --on-event fish_preexec
echo \e\[\?1004l
end
__fish_enable_focus
end
function __fish_winch_handler --on-signal WINCH -d "Repaint screen when window changes size"
commandline -f repaint >/dev/null 2>/dev/null
end

View file

@ -107,6 +107,16 @@ function __fish_shared_key_bindings -d "Bindings shared between emacs and vi mod
bind --preset $argv \ee edit_command_buffer
bind --preset $argv \ev edit_command_buffer
# Tmux' focus events.
# Exclude paste mode because that should get _everything_ literally.
for mode in (bind --list-modes | string match -v paste)
# We only need the in-focus event currently (to redraw the vi-cursor).
bind -M $mode \e\[I 'emit fish_focus_in'
bind -M $mode \e\[O false
bind -M $mode \e\[\?1004h false
end
# Support for "bracketed paste"
# The way it works is that we acknowledge our support by printing
# \e\[?2004h

View file

@ -84,11 +84,6 @@ function fish_default_key_bindings -d "Default (Emacs-like) key bindings for fis
bind --preset $argv \ed kill-word
# Ignore some known-bad control sequences
# https://github.com/fish-shell/fish-shell/issues/1917
bind --preset $argv \e\[I 'begin;end'
bind --preset $argv \e\[O 'begin;end'
# term-specific special bindings
switch "$TERM"
case 'rxvt*'

View file

@ -107,7 +107,7 @@ function fish_vi_cursor -d 'Set cursor shape for different vi modes'
or set -g fish_cursor_unknown block blink
echo "
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in
set -l varname fish_cursor_\$fish_bind_mode
if not set -q \$varname
set varname fish_cursor_unknown