Skip to content
copy to local clipboard

copy to local clipboard

I’m used to piping things into my local macOS clipboard using | pbcopy all day long, here’s a way to get the same results when connected to a remote system via ssh.

just add this as a function into your dotfiles, like .zshrc, or .zsh_aliases, or .bashrc etc.:

pbcopy() {
  printf '\e]52;c;%s\a' "$(base64 | tr -d '\n')"
}

I’m managing my dotfiles using chezmoi and have a template so the above function will only be applied to linux hosts, that’s why I picked the same name as I’m already familiar with from macOS.