-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathftp.sh
executable file
·70 lines (56 loc) · 2.47 KB
/
ftp.sh
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env bash
source $(dirname "$0")/config.sh
clipboard=$(xclip -o -selection clipboard -t image/png 2> /dev/null)
if [[ "target image/png not available" == *"$clipboard"* ]]; then
echo "No image found on clipboard!"
exit 1
fi
emojis=(😀 😁 😂 🤣 😃 😄 😅 😆 😉 😊 😋 😎 😍 😘 🥰 😗 😙 😚 ☺ 🙂 🤗 🤩 🤔 🤨 😐 😑 😶 🙄 😏 😣 😥 😮 🤐 😯 😪 😫 😴 😌 😛 😜 😝 🤤 😒 😓 😔 😕 🙃 🤑 😲 ☹ 🙁 😖 😞 😟 😤 😢 😭 😦 😧 😨 😩 🤯 😬 😰 😱 🥵 🥶 😳 🤪 😵 😡 😠 🤬 😷 🤒 🤕 🤢 🤮 🤧 😇 🤠 🤡 🥳 🥴 🥺 🤥 🤫 🤭 🧐 🤓 😈 👿 👹 👺 💀 ☠ 👻 👽 👾 🤖 💩 😺 😸 😹 😻 😼 😽 🙀 😿 😾 👶 👦 👧 👨 👩 👴 👵 👮 🕵 💂 👷 🤴 👸 👳 👲 🧕 🧔 👱 🤵 👰 🤰 🤱 👼 🎅 🤶 🦸 🦹 🧙 🧛 🧜 🧝 🧞 🧟 🙍 🙎 🙅 🙆 💁 🙋 🙇 🤦 🤷 💆 💇 🚶 🏃 💃 🕺 👯 🧖 🧘 🕴 🗣 👤 👥 👫 👬 👭 💏 💑 👪 🤳 💪 🦵 🦶 👈 👉 ☝ 👆 🖕 👇 ✌ 🤞 🖖 🤘 🤙 🖐 ✋ 👌 👍 👎 ✊ 👊 🤛 🤜 🤚 👋 🤟 ✍ 👏 👐 🙌 🤲 🙏 🤝 💅 👂 👃 👣 👀 👁 🧠 🦴 🦷 👅 👄 💋 👓 🕶 🥽 🥼 👔 👕 👖 🧣 🧤 🧥 🧦 👗 👘 👙 👚 👛 👜 👝 🎒 👞 👟 🥾 🥿 👠 👡 👢 👑 👒 🎩 🎓 🧢 ⛑ 💄 💍 🧳 🌂 ☂ 💼 🧵 🧶)
declare name
declare -i opt_quiet
declare -i opt_new_window
while (($#)); do
case "$1" in
-e)
for ((i=0; i<5; i++)); do
name="${name}${emojis[RANDOM % 256]}"
done
;;
-q)
opt_quiet=1
;;
-w)
opt_new_window=1
;;
*)
printf "error: unrecognized argument '$1'\n" >&2
exit 1
;;
esac
shift
done
if [[ -z "${name}" ]]; then
name="$(cat /dev/urandom \
| tr -dc 'a-zA-Z0-9' \
| fold -w "${FILE_NAME_LENGTH}" \
| head -n 1)"
fi
xclip -o -selection clipboard -t image/png -o > "$name.png"
upload_dir=$(echo "$UPLOAD_PATH/$name.png" | tr -s /)
echo "$upload_dir"
ftp -n "$HOST" <<END_SCRIPT
quote USER "$USERNAME"
quote PASS "$PASSWORD"
passive
binary
put "$name.png" "${upload_dir#/}"
END_SCRIPT
rm "$name.png"
url="$BASE_REDIRECT_URL/${upload_dir#/}"
echo -n $url | xclip -i -selection clipboard
if ((! opt_quiet)); then
echo "$url"
fi
if ((opt_new_window)); then
xdg-open "$url"
fi