summaryrefslogtreecommitdiff
path: root/xpaste
blob: 77aa84211a853bd4fe7f40cc5dad99a6b5689ebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/sh -e
#
# Copyright (C) 2023 dwlr <dweller@cabin.digital>
#
# BSD 3-Clause License (BSD-3-Clause)
# See LICENSE for details


# NOTE: awk part does URI decoding
xclip -sel clipboard -o -r -t text/uri-list | cut -d':' -f2- | tr -d '\r' \
| awk -niord '{printf RT?$0chr("0x"substr(RT,2)):$0}' RS=%.. \
| while IFS= read -r path
do
    if [ -e "$path" ]; then
        cp -v -r "$path" "$(basename "$path")"
    fi
done