32 lines
807 B
Fish
Executable file
32 lines
807 B
Fish
Executable file
#!/usr/bin/env fish
|
|
|
|
# script takes the clipboard contents and
|
|
# trims/adds newlines appropriately to force
|
|
# inline or above/below line paste
|
|
|
|
# In helix, if there's a trailing newline, it's pasted linewise
|
|
# Otherwise it's pasted inline
|
|
|
|
set -l cmd $argv[1]
|
|
# get clip contents, and preserve newlines
|
|
set -l contents (wl-paste -n | string collect -N)
|
|
count "$contents"
|
|
if test "$cmd" = inline
|
|
# if there's more than 1 newline, it
|
|
# has to be linewise
|
|
set -l lines (string split -n \n "$contents")
|
|
set -S lines
|
|
|
|
printf "%s" "$(string join \n "$lines")"
|
|
# if test "$newlines" -eq 1
|
|
# printf "%s" (string trim --chars \n "$contents")
|
|
# else
|
|
# printf "%s" "$contents"
|
|
# end
|
|
|
|
else if test "$cmd" = linewise
|
|
# test if the last line has a
|
|
|
|
end
|
|
|
|
# echo paste-util
|