Skip to content

Copy to clipboard support

WebSSH1 supports2 OSC52 terminal escape sequence that allows copying text to the clipboard from within the terminal. It is supported by many other3 terminal emulators, including xterm, gnome-terminal, and iTerm2.

How to copy output to the clipboard?

It's simple as :

  • cat filename.txt | wshcopy
  • echo "WebSSH is awesome!" | wshcopy

wshcopy will handle the output and send it to WebSSH by using "invisible" terminal chars.

Daemon hides under terminal

As the terminal can do "untrusted" things, WebSSH will ask you (by default) if you approve or deny the clipboard access.

You can change this behavior inside WebSSH settings (iOS : within system settings > WebSSH / macOS : within the app settings).

How to install wshcopy

pip3 install webssh-sh

How to use with tmux >= 3.3

  • set -g allow-passthrough on THEN echo "WebSSH is awesome!" | wshcopy -t tmux
  • OR
  • set -g set-clipboard on THEN echo "WebSSH is awesome!" | wshcopy -t default

I would like to improve wshcopy πŸ˜›

Repository is here : webssh-sh

Documentation about OSC52 Terminal Escape Sequence

OSC 52 Sequence

The sequence consists of the following: OSC 52 ; Pc ; Pd BEL

  • Pc is the clipboard choice:
Choice Description Supported by WebSSH
c clipboard βœ…
p primary ❌
q secondary ❌
s select ❌
0-7 cut-buffers ❌
  • Pd is the data to copy to the clipboard. This string should be encoded in base64 RFC-4648.
  • If Pd is "?", the terminal replies to the host with the current contents of the clipboard.
  • If Pd is neither a base64 string nor "?", the terminal clears the clipboard.

  1. Since 20.5 

  2. Only copy to clipboard 

  3. https://github.com/ojroques/vim-oscyank/blob/main/README.md 


Last update: November 25, 2022