Closed JonathanWheeler closed 3 years ago
Hi, thanks for this PR! :+1: But unfortunately, this change ends up adding {
curly braces }
to the copied text on my system (tested under multiple shells: ZSH, BASH, DASH, and POSIX). :disappointed: Instead, we'll need to communicate this issue upstream to the tmux developers and ask them to support a special --
separator flag that can be used like this:
tmux set-buffer -- "- foo"
That's interesting! It's working on my end. I wonder what the discrepancy is? I've tested it on macOS 10.15.7 + iTerm2 3.3.12 + zsh 5.7.1 (+ with and without vim 8.1), and on Ubuntu 20.04.1 + GNOME Terminal 3.36.2 + zsh 5.8 + tmux next-3.3 (tmux 3.2-rc2, I think) (+ with and without vim 8.1). I've left the #!/bin/sh
shebang intact.
Nevertheless, your suggestion would be a more elegant solution.
... OK, I just noticed that I get the same curly brace result when I type tmux set-buffer {"- foo"}
into the command line (both zsh & sh), but it's working for me when it's executed inside the script (sh) when copying some text beginning with -
. I'm not sure why. (Or why it even works at all, lol.)
Did you test it by adding it to the script?
I've tried this now by adding braces to a script, but still no luck:
$ echo 'tmux set-buffer {"- foo"}' > /tmp/with-braces
$ dash -eux /tmp/with-braces
+ tmux set-buffer {- foo}
$ tmux save-buffer - | od -ca
0000000 { - f o o }
{ - sp f o o }
0000007
$ tmux delete-buffer
$ tmux save-buffer -
no buffers
And the same thing happens when the script is executed directly:
$ (echo '#!/bin/sh'; echo 'tmux set-buffer {"- foo"}') > /tmp/with-braces
$ chmod +x /tmp/with-braces
$ /tmp/with-braces
$ tmux save-buffer - | od -ca
0000000 { - f o o }
{ - sp f o o }
0000007
$ tmux delete-buffer
$ tmux save-buffer -
no buffers
For completeness, here is the case of not adding braces to a script:
$ echo 'tmux set-buffer "- foo"' > /tmp/sans-braces
$ dash -eux /tmp/sans-braces
+ tmux set-buffer - foo
tmux: unknown option --
usage: set-buffer [-aw] [-b buffer-name] [-n new-buffer-name] [-t target-client] data
$ tmux save-buffer - | od -ca
no buffers
0000000
Unfortunately, I don't understand how or why it's even working on your system. :sweat_smile: So I'm closing this PR now, since I couldn't reproduce your results on my system (as shown in my experiments above). Nevertheless, thanks for your contribution. :+1: Cheers.
As also noted here, fixes the following issue: