-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHOWTO
More file actions
55 lines (46 loc) · 1.24 KB
/
HOWTO
File metadata and controls
55 lines (46 loc) · 1.24 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
49
50
51
52
53
54
55
# CLI stupidly simple sharing.
#
# Does exactly what it seems. Support various formats.
# Binary-friendly blobs.
#
# Depends on `curl' for http communication.
# Depends on `scrot' for interactive screenshot.
#
# Put it in your shell:
# bash $ curl -Ss '__URL__' >> ~/.bashrc
# zsh % curl -Ss '__URL__' >> ~/.zprofile
function lolbin {
url="__URL__"
if [ -p /dev/stdin ]; then
arg="@-"
elif [ -f "$1" ]; then
arg="@$1"
else
return 1
fi
blob_id=$(curl -Ss "${url}" -F "file=${arg}")
blob_url="${url}${blob_id}"
command -v xclip 2>&1 >/dev/null && (echo -n "${blob_url}" | xclip -selection clipboard -in)
echo "${blob_url}"
}
function lolimg() {
url="__URL__"
if [ -p /dev/stdin ]; then
arg="@-"
elif [ -f "$1" ]; then
arg="@$1"
else
filepath=$(mktemp -u --suffix=.png)
scrot -F "${filepath}" -s #-e 'optipng $f'
arg="@${filepath}"
fi
blob_id=$(curl -Ss "${url}" -F "file=${arg}")
blob_url="${url}${blob_id}"
[[ -f "${filepath}" ]] && rm -f "${filepath}"
command -v xclip 2>&1 >/dev/null && (echo -n "${blob_url}" | xclip -selection clipboard -in)
echo "${blob_url}"
}
# Usage examples:
# $ lolbin /path/to/file
# $ cat /path/to/file | lolbin
# $ lolimg ## scrot selection