Skip to content

IvanVolosyuk/mosh-kitty-hack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copy paste using kitty/mosh/tmux/neovim using OSC52.

There are several major issues with this setup.

  1. Incompatible OSC52 settings between mosh and tmux. Fix in tmux config.
  2. Mosh ignores fetching copy paste buffer as it thinks it has latest one. Fix in multiple places.
  3. Limited clipboard size in mosh. (The idea is to save copy buffer to a local file in addition to setting the clipboard. It seems I didn't actually implement that.)

Tmux config

Here is the tmux config: - Send ! which will be ignored by patched kitty to force exchanging selection buffers. - Setup clipboard support - Override yank from tmux to use the same system (yank).

# Send unsupported ! command to reset mosh buffer and request selection.
set-option -ag terminal-overrides ",xterm-256color:Ms=\\E]52;c;!\\7\\E]52;c%p1%.0s;%p2%s\\7"

set -g allow-passthrough on
set-window-option -g allow-passthrough on

bind-key -T copy-mode-vi a send-keys -X cancel
bind-key -T copy-mode-vi i send-keys -X cancel
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
set -g mouse on

# Initiate copy mode
bind-key -T prefix v copy-mode

# Seem important
set-option -s set-clipboard on
set -s copy-command 'yank > #{pane_tty}'

# Allow tmux yank to interact with copy paste buffer.
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'yank >#{pane_tty}'
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel 'yank >#{pane_tty}'
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pip-and-cancel 'yank >#{pane_tty}'

Kitty's host config

I enable clipboard access. No append is kinda unfortunate, but I still have to figure out how to stream clipboard via mosh.

clipboard_control write-clipboard write-primary read-primary read-clipboard no-append
clipboard_max_size 132872

Neovim

I set this up in vimscript config file to use my copy and paste binaries. There is already paste in standard commands, so I named mine 'pop'.

let g:clipboard = {
      \   'name': 'myClipboard',
      \   'copy': {
      \      '+': ['yank'],
      \      '*': ['yank'],
      \    },
      \   'paste': {
      \      '+': ['pop'],
      \      '*': ['pop'],
      \   },
      \   'cache_enabled': 1,
      \ }

Kitty's patch

https://github.com/IvanVolosyuk/kitty/tree/mosh-hack

Yank / pop

The binaries I use to interect with clipboard, which have workarounds for various modes of execution. Can be used within ssh, tmux, mosh, neovim, etc.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors