File: xclip-copyfile

package info (click to toggle)
xclip 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 344 kB
  • sloc: ansic: 1,282; sh: 267; makefile: 75
file content (22 lines) | stat: -rwxr-xr-x 572 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh
set -e
if [ "x$1" = "x" ]; then
    echo "Usage: [options] $0 file..." >&2
    echo "-p Copy path information; preserve tree structure"
    exit 1
fi
archive=`mktemp` || exit 1
trap 'rm -f "${archive}"' 1 2 3 15
if [ "x$1" = "x-p" ]; then
    tar cf "${archive}" "$@"
else
    flags="cf"
    for file in "$@"; do
        filedir=`dirname "${file}"`
        filename=`basename "${file}"`
        tar "${flags}" "${archive}" -C "${filedir}" "${filename}"
        flags="rf"
    done
fi
gzip -c "${archive}" | xclip -selection secondary -loops 1 -i
rm "${archive}"