-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathix
More file actions
executable file
·46 lines (38 loc) · 792 Bytes
/
ix
File metadata and controls
executable file
·46 lines (38 loc) · 792 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
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash
set -e
set -o pipefail
usage() {
echo 'Usage: command | ix
Terminal pastebin replacement
Flags:
-v: prints what it received as STDIN back to STDOUT
Can be used to send lines from vim to ix like:
<number of lines>!!ix -v
See https://purarue.xyz/x/notes/programming/languages/shell_tools/vim/magic_wands/'
exit "${1:-0}"
}
declare verbose=0
while getopts "vh" OPT; do
case "$OPT" in
v)
verbose=1
;;
h)
usage 0
;;
*)
printf 'Unknown flag %s\n' "$OPT" >&2
usage 1
;;
esac
done
declare stdin
stdin="$(cat)"
((verbose)) && cat <<<"${stdin}"
declare url
url="$(curl -s -F 'f:1=<-' http://ix.io <<<"${stdin}")" || {
notify "Failed to make request to http://ix.io"
exit 1
}
printf '%s' "${url}" | clipcopy
notify "Copied link to clipboard" "${url}"