File: xclip.sh

package info (click to toggle)
clifm 1.26.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,816 kB
  • sloc: ansic: 64,595; sh: 3,133; python: 1,851; makefile: 567
file content (41 lines) | stat: -rwxr-xr-x 1,250 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh

# Description: Copy the contents of the line buffer to the clipboard
# Dependencies:
#  Any of the following: cb, wl-copy, xclip, xsel, pbcopy, termux-clipboard-set, clipboard, or clip
# License: GPL2+
# Author: L. Abramovich

# Bound by default to Ctrl-y

if [ -z "$CLIFM_LINE" ]; then
	printf "clifm: Empty line buffer\n" 2>&1
	exit 1
fi

line="$CLIFM_LINE"
# Manipulate LINE as you wish here, for example, to get only the last field
#line="$(echo "$CLIFM_LINE" | awk '{print $NF}')"

if type cb >/dev/null 2>&1; then
	printf "%s" "$line" | cb --copy
elif [ -n "$WAYLAND_DISPLAY" ]; then
	printf "%s" "$line" | wl-copy
elif type xclip >/dev/null 2>&1; then
	printf "%s" "$line" | xclip -sel clip
elif type xsel >/dev/null 2>&1; then
	printf "%s" "$line" | xsel -bi
elif type pbcopy >/dev/null 2>&1; then # MacOS
	printf "%s" "$line" | pbcopy
elif type termux-clipboard-set >/dev/null 2>&1; then
	printf "%s" "$line" | termux-clipboard-set
elif type clipboard >/dev/null 2>&1; then # Haiku
	printf "%s" "$line" | clipboard --stdin
elif type clip >/dev/null 2>&1; then # Cygwin
	printf "%s" "$line" | clip
else
	printf "clifm: No clipboard application found\n" 2>&1
	exit 1
fi

printf "\x1b[0mclifm: Line buffer copied to the clipboard\n"