2023-01-27 17:09:48 -03:00
|
|
|
#!/usr/bin/env fish
|
|
|
|
|
|
|
|
function die
|
|
|
|
echo $argv[2..] >&2
|
|
|
|
exit $argv[1]
|
|
|
|
end
|
|
|
|
|
|
|
|
if test (count $argv) != 1
|
|
|
|
die 1 "Incorrect number of arguments porvided" >&2
|
|
|
|
end
|
|
|
|
|
|
|
|
set -a file (realpath $argv[1])
|
2024-02-06 20:54:50 -03:00
|
|
|
set -a url (string escape --style=url "$file")
|
2023-01-27 17:09:48 -03:00
|
|
|
set -e argv[1]
|
|
|
|
|
|
|
|
if test -d "$file"
|
|
|
|
die 1 "Cannot copy directories" >&2
|
|
|
|
else if test -f "$file"
|
2024-02-06 20:54:50 -03:00
|
|
|
wl-copy $argv -t text/uri-list "file:///$url"
|
2023-01-27 17:09:48 -03:00
|
|
|
else
|
|
|
|
die 2 "No file found" >&2
|
|
|
|
end
|