File: copy_files.sh

package info (click to toggle)
copyq 3.7.3-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 10,480 kB
  • sloc: cpp: 51,894; sh: 734; python: 211; xml: 57; makefile: 34
file content (23 lines) | stat: -rwxr-xr-x 489 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Save whole files in CopyQ.
# USAGE:
#   utils/copy_files.sh [FILES...]
# EXAMPLE:
#   TAB=images utils/copy_files.sh ~/Pictures/*.jpg
COPYQ=${COPYQ:-copyq}
TAB=${TAB:-files}

set -e

i=0
for x in "$@"; do
    # get MIME
    mime=$(file -b -L --mime-type "$x")
    # print info
    printf "%s: %s\n" "$mime" "$x"
    # write image with label
    "$COPYQ" -s "$SESSION" tab "$TAB" write $((++i)) \
        "application/x-copyq-item-notes" "$x" \
        "$mime" - < "$x"
done