..
How to copy text from remote server to clipboard?
First define this bash function:
# Add to remote ~/.bashrc
clip() {
# Read from stdin, encode to base64 (disable wrapping with -w 0),
# and wrap in the OSC 52 escape sequence.
local b64
b64=$(cat | base64 -w 0)
printf "\033]52;c;%s\a" "$b64"
}or for fish:
function clip
# Read from stdin, encode to base64, and save to a local variable
set -l b64 (cat | base64 -w 0)
# Output the OSC 52 sequence directly to the terminal
printf "\033]52;c;%s\a" "$b64"
endThen you can easily run:
cat file.txt | clipNote that if you use tmux you should allow clipboard:
set-clipboard on