kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.2k stars 972 forks source link

Kitty + Tmux + OSC52 results in broken copy-paste? #5604

Closed triebelf closed 1 year ago

triebelf commented 1 year ago

Describe the bug When copying text in Kitty with ssh session and remote tmux, text is appended to clipboard instead of overwriting the clipboard contents.

To Reproduce Steps to reproduce the behavior:

  1. start Kitty
  2. ssh to other server
  3. start tmux on other server
  4. copy text
  5. paste text on client

Environment details within tmux remote session:

echo $TERM
tmux-256color

tmux config:

# set the correct term
set -g default-terminal "tmux-256color"
set -sa terminal-overrides ",*256col*:RGB"

# force zsh if user default shell if fixed
set -g default-shell "/bin/zsh"

# count from one, not zero
set -g base-index 1

set -g status-interval 5
set -g set-titles on
set -g focus-events on
set -g automatic-rename on
setw -g aggressive-resize on

# limit the scrollback buffer
set -g history-limit 100000

# vi key bindings
setw -g mode-keys vi

# change default prefix
unbind-key C-b
set -g prefix C-a
bind-key C-a send-prefix

unbind-key [
unbind-key ]
set -s escape-time 0
bind-key Escape copy-mode
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel
bind-key C-p paste-buffer
set -s set-clipboard on

on client:

❯ kitty --debug-config 
kitty 0.15.0 created by Kovid Goyal
Linux LR-Z9799 5.15.0-50-generic #56~20.04.1-Ubuntu SMP Tue Sep 27 15:51:29 UTC 2022 x86_64
Ubuntu 20.04.5 LTS \n \l
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
Loaded config files: /etc/xdg/kitty/kitty.conf, /home/ftr8fe/.config/kitty/kitty.conf
Running under: X11

Config options different from defaults:
active_tab_background   Color(red=122, green=162, blue=247)
active_tab_foreground   Color(red=22, green=22, blue=30)
background              Color(red=26, green=27, blue=38)
color0                  Color(red=21, green=22, blue=30)
color1                  Color(red=247, green=118, blue=142)
color10                 Color(red=158, green=206, blue=106)
color11                 Color(red=224, green=175, blue=104)
color12                 Color(red=122, green=162, blue=247)
color13                 Color(red=187, green=154, blue=247)
color14                 Color(red=125, green=207, blue=255)
color15                 Color(red=192, green=202, blue=245)
color16                 Color(red=255, green=158, blue=100)
color17                 Color(red=219, green=75, blue=75)
color2                  Color(red=158, green=206, blue=106)
color3                  Color(red=224, green=175, blue=104)
color4                  Color(red=122, green=162, blue=247)
color5                  Color(red=187, green=154, blue=247)
color6                  Color(red=125, green=207, blue=255)
color7                  Color(red=169, green=177, blue=214)
color8                  Color(red=65, green=72, blue=104)
color9                  Color(red=247, green=118, blue=142)
cursor                  Color(red=192, green=202, blue=245)
cursor_text_color       Color(red=26, green=27, blue=38)
font_family             Fira Code
font_size               13.0
foreground              Color(red=192, green=202, blue=245)
hide_window_decorations True
inactive_tab_background Color(red=41, green=46, blue=66)
inactive_tab_foreground Color(red=84, green=92, blue=126)
selection_background    Color(red=51, green=70, blue=124)
selection_foreground    Color(red=192, green=202, blue=245)
shell                   zsh
update_check_interval   0.0
url_color               Color(red=115, green=218, blue=202)
Added shortcuts:
    shift+control+plus KeyAction(func='change_font_size', args=[True, '+', 1.0])
    shift+control+kp_subtract KeyAction(func='change_font_size', args=[True, '-', 1.0])
    shift+control+kp_add KeyAction(func='change_font_size', args=[True, '+', 1.0])
Removed shortcuts:
    shift+insert KeyAction(func='paste_from_selection', args=())
    shift+control+comma KeyAction(func='move_tab_backward', args=())
    shift+control+period KeyAction(func='move_tab_forward', args=())
    shift+control+0 KeyAction(func='tenth_window', args=())
    shift+control+1 KeyAction(func='first_window', args=())
    shift+control+2 KeyAction(func='second_window', args=())
    shift+control+3 KeyAction(func='third_window', args=())
    shift+control+4 KeyAction(func='fourth_window', args=())
    shift+control+5 KeyAction(func='fifth_window', args=())
    shift+control+6 KeyAction(func='sixth_window', args=())
    shift+control+7 KeyAction(func='seventh_window', args=())
    shift+control+8 KeyAction(func='eighth_window', args=())
    shift+control+9 KeyAction(func='ninth_window', args=())
    shift+control+equal KeyAction(func='change_font_size', args=[True, '+', 2.0])
    shift+control+a > 1 KeyAction(func='set_background_opacity', args=['1'])
    shift+control+a > d KeyAction(func='set_background_opacity', args=['default'])
    shift+control+a > l KeyAction(func='set_background_opacity', args=['-0.1'])
    shift+control+a > m KeyAction(func='set_background_opacity', args=['+0.1'])
    shift+control+b KeyAction(func='move_window_backward', args=())
    shift+control+e KeyAction(func='kitten', args=['hints'])
    shift+control+f KeyAction(func='move_window_forward', args=())
    shift+control+h KeyAction(func='show_scrollback', args=())
    shift+control+j KeyAction(func='scroll_line_down', args=())
    shift+control+k KeyAction(func='scroll_line_up', args=())
    shift+control+l KeyAction(func='next_layout', args=())
    shift+control+n KeyAction(func='new_os_window', args=())
    shift+control+o KeyAction(func='pass_selection_to_program', args=())
    shift+control+p > f KeyAction(func='kitten', args=['hints', '--type path --program -'])
    shift+control+p > h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
    shift+control+p > l KeyAction(func='kitten', args=['hints', '--type line --program -'])
    shift+control+p > w KeyAction(func='kitten', args=['hints', '--type word --program -'])
    shift+control+p > shift+f KeyAction(func='kitten', args=['hints', '--type path'])
    shift+control+q KeyAction(func='close_tab', args=())
    shift+control+r KeyAction(func='start_resizing_window', args=())
    shift+control+s KeyAction(func='paste_from_selection', args=())
    shift+control+t KeyAction(func='new_tab', args=())
    shift+control+u KeyAction(func='kitten', args=['unicode_input'])
    shift+control+w KeyAction(func='close_window', args=())
    shift+control+left_bracket KeyAction(func='previous_window', args=())
    shift+control+right_bracket KeyAction(func='next_window', args=())
    shift+control+grave_accent KeyAction(func='move_window_to_top', args=())
    shift+control+escape KeyAction(func='kitty_shell', args=['window'])
    shift+control+enter KeyAction(func='new_window', args=())
    shift+control+delete KeyAction(func='clear_terminal', args=['reset', True])
    shift+control+right KeyAction(func='next_tab', args=())
    shift+control+left KeyAction(func='previous_tab', args=())
    shift+control+down KeyAction(func='scroll_line_down', args=())
    shift+control+up KeyAction(func='scroll_line_up', args=())
    shift+control+page_up KeyAction(func='scroll_page_up', args=())
    shift+control+page_down KeyAction(func='scroll_page_down', args=())
    shift+control+home KeyAction(func='scroll_home', args=())
    shift+control+end KeyAction(func='scroll_end', args=())
    shift+control+f2 KeyAction(func='edit_config_file', args=())
    shift+control+f10 KeyAction(func='toggle_maximized', args=())
    shift+control+f11 KeyAction(func='toggle_fullscreen', args=())
    shift+control+alt+t KeyAction(func='set_tab_title', args=())
Changed shortcuts:
    shift+control+minus KeyAction(func='change_font_size', args=[True, '-', 1.0])

Additional context Same problem with kitty --config NONE.

It works with other terminals (Alacritty), that support OSC52 escape codes.

It also works if there is no tmux session on the remote server. I suspect it has something to do with the terminal capabilities. Is tmux and Kitty compatible?

kovidgoyal commented 1 year ago

Your version of kitty is too old, update.