mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 13:23:53 +08:00
fish_clipboard_copy: Stop adding newlines
When this switched over from directly piping commandline to storing
its output and using printf, I inadvertently always added a trailing
newline. That's probably annoying.
Note that this will now always *remove* a trailing newline (because
the command substitution does). That will barely make a
difference (because trailing newlines are quite unusual in the
commandline) and will probably feel better than keeping it - we could
even make a point of removing trailing whitespace in general.
Fixes #6927
(cherry picked from commit 6ebbe5a450
)
This commit is contained in:
parent
5f6e43df6a
commit
d9cf1be4b7
|
@ -3,14 +3,14 @@ function fish_clipboard_copy
|
||||||
set -l cmdline (commandline --current-selection)
|
set -l cmdline (commandline --current-selection)
|
||||||
test -n "$cmdline"; or set cmdline (commandline)
|
test -n "$cmdline"; or set cmdline (commandline)
|
||||||
if type -q pbcopy
|
if type -q pbcopy
|
||||||
printf '%s\n' $cmdline | pbcopy
|
printf '%s' $cmdline | pbcopy
|
||||||
else if set -q WAYLAND_DISPLAY; and type -q wl-copy
|
else if set -q WAYLAND_DISPLAY; and type -q wl-copy
|
||||||
printf '%s\n' $cmdline | wl-copy
|
printf '%s' $cmdline | wl-copy
|
||||||
else if type -q xsel
|
else if type -q xsel
|
||||||
# Silence error so no error message shows up
|
# Silence error so no error message shows up
|
||||||
# if e.g. X isn't running.
|
# if e.g. X isn't running.
|
||||||
printf '%s\n' $cmdline | xsel --clipboard 2>/dev/null
|
printf '%s' $cmdline | xsel --clipboard 2>/dev/null
|
||||||
else if type -q xclip
|
else if type -q xclip
|
||||||
printf '%s\n' $cmdline | xclip -selection clipboard 2>/dev/null
|
printf '%s' $cmdline | xclip -selection clipboard 2>/dev/null
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user