-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclip-filename
More file actions
executable file
·48 lines (39 loc) · 1.02 KB
/
clip-filename
File metadata and controls
executable file
·48 lines (39 loc) · 1.02 KB
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
42
43
44
45
46
47
48
#!/bin/bash
# Copy complete file name to middle-click clipboard
# --win: Use windows directory
USEWIN=0
if [ "$1" == "win" -o "$1" == "--win" -o "$1" == "-w" ]; then
# Use windows path instead
USEWIN=1
shift
fi
# Also special handling of "\ " --> " " otherwise you cannot paste it into GUI
# programs
INFILE="${1//\\ / }"
echo "$INFILE"
if [ -z "$INFILE" ]; then
echo "Copy complete file name to middle-click clipboard"
echo "call with $0 [--win] filename"
fi
if [ $USEWIN -eq 1 ]; then
# Use windows path instead
INFILE="$(cygpath --absolute --windows "$INFILE")"
else
# Canonialize INFILE
if [[ ${INFILE} == */* ]]; then
# Take care when we are not in current directory - but this resolved links
# (not always wanted)
INFILE=$(readlink -m "${INFILE}")
else
INFILE="${PWD}/${INFILE}"
fi
fi
if [ "${OS}" == "Windows_NT" ]; then
# Cygwin
echo -n "$INFILE" | putclip
else
# Linux
echo -n "$INFILE" | xclip -selection primary
fi
echo "Put to middle-click clipoard:"
echo "$INFILE"