mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
6ebbe5a450
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
16 lines
649 B
Fish
16 lines
649 B
Fish
function fish_clipboard_copy
|
|
# Copy the current selection, or the entire commandline if that is empty.
|
|
set -l cmdline (commandline --current-selection)
|
|
test -n "$cmdline"; or set cmdline (commandline)
|
|
if type -q pbcopy
|
|
printf '%s' $cmdline | pbcopy
|
|
else if set -q WAYLAND_DISPLAY; and type -q wl-copy
|
|
printf '%s' $cmdline | wl-copy
|
|
else if type -q xsel
|
|
# Silence error so no error message shows up
|
|
# if e.g. X isn't running.
|
|
printf '%s' $cmdline | xsel --clipboard 2>/dev/null
|
|
else if type -q xclip
|
|
printf '%s' $cmdline | xclip -selection clipboard 2>/dev/null
|
|
end
|
|
end
|