Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL clip.exe doesn't support utf8 characters #144

Open
melink14 opened this issue Aug 8, 2020 · 2 comments
Open

WSL clip.exe doesn't support utf8 characters #144

melink14 opened this issue Aug 8, 2020 · 2 comments

Comments

@melink14
Copy link

melink14 commented Aug 8, 2020

Noticed this while working on some Japanese parsing but whenever I copied with tmux yank, the later paste would be garbled text.

Eventually, tracked it down to clip.exe not supporting it. For full support there are two reasonable options:

  1. powershell.exe -command "Set-Clipboard" -Value "text to copy" which most WSL environments probably already have but would require some work to accept the argument from STDIN. (bash function or script)

  2. utf8clip dotnet program which works just like clip.exe but handles utf8. I chose to use this one and there's no issue either though it was probably a bit more work than 1 in the end...

I used a if-shell conditional to only override the command if the better command existed to make it easier to share my dotfiles.

@menghuu
Copy link

menghuu commented Apr 7, 2023

I add those in my .tmux.conf, it works

if-shell '[ -n "$WSL_DISTRO_NAME" ] && command -v powershell.exe >/dev/null 2>&1' {
  set -g @override_copy_command \
  'customclip(){ local STDIN=$(cat -); powershell.exe -command "Set-Clipboard" -Value "$STDIN"; }; customclip'
}

@bigwheel
Copy link

I add those in my .tmux.conf, it works

if-shell '[ -n "$WSL_DISTRO_NAME" ] && command -v powershell.exe >/dev/null 2>&1' {
  set -g @override_copy_command \
  'customclip(){ local STDIN=$(cat -); powershell.exe -command "Set-Clipboard" -Value "$STDIN"; }; customclip'
}

With multiline text, this doesn't work.
Finally I decide to use xsel. It works well with multiline.

if-shell '[ -n "$WSL_DISTRO_NAME" ] && command -v powershell.exe >/dev/null 2>&1' {
  set -g @override_copy_command 'xsel -i --clipboard'
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants