-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpcl
More file actions
executable file
·37 lines (28 loc) · 786 Bytes
/
cpcl
File metadata and controls
executable file
·37 lines (28 loc) · 786 Bytes
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
#!/bin/bash
# Copies file to current dir and puts full path into xclipboard. If file is in current dir then just does xclipboard. If no file then just puts pwd in xclipboard.
# Requires xclip installed.
if [[ $# -gt 1 ]] ; then
echo "Just give me one single file or give me none."
exit
fi
if [[ ! $# == 0 ]] && [[ ! -f $1 ]] ; then
echo "Can't find the file $1."
exit
fi
command -v xclip > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
echo "I need xclip but I can't find it."
exit
fi
dirn=`dirname "$1"`
filen=`basename "$1"`
if [[ "$dirn" != "." ]]; then
cp -iv "$1" .
fi
echo "Copied to clipboard: `pwd`/$filen"
echo -n "`pwd`/$filen"|xclip
# echo "[Enter] to copy filename only to clipboard"
# read -n1 -s
#
# echo "Copied to clipboard: $filen"
# echo -n "$filen"|xclip