forked from milianw/shell-helpers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaste
executable file
·40 lines (31 loc) · 875 Bytes
/
paste
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
#!/bin/bash
#
# This program uses the pastebinit program and a KDE4 klipper instance
# to paste fast and conveniently from a console.
# see man pastebinit and it's -b argument
target="http://paste.kde.org/~mwolff/"
# get clipboard contents from klipper
toPaste=$(clipboard)
if [[ "$(echo $toPaste | wc -l)" == "1" && "$(echo $toPaste | grep $target)" ]]; then
echo "cancelling, not pasting '$toPaste' - looks useless"
exit
fi
# see man pastebinit and it's -f argument
formatting="text"
if [[ "$1" != "" ]]; then
formatting="$1"
fi
# paste
echo "will paste the following to $target:"
echo
echo $toPaste
echo
echo -n "... pasting ..."
pasteUrl=$(echo -n "$toPaste" | pastebinit -f "$formatting" -b "$target")
trim() { echo $1; }
pasteUrl=$(trim $pasteUrl)
echo " done"
echo
echo "pasted to $pasteUrl"
# set klipper contents to pasteUrl
echo $pasteUrl | clipboard