forked from matryer/xbar-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclipboard-base64-encoder.sh
executable file
·39 lines (31 loc) · 1.4 KB
/
clipboard-base64-encoder.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
#!/bin/bash
# <bitbar.title>Clipboard BASE64-Encoder</bitbar.title>
# <bitbar.version>v0.1</bitbar.version>
# <bitbar.author>Steffen Froehlich</bitbar.author>
# <bitbar.author.github>citoki</bitbar.author.github>
# <bitbar.desc>This plugin will encode acutal clipboard item with BASE64.
# The result will be available in clipboard again. Do not use the result
# for cryptographic purposes!!
# It's inspired by the original clipboard-history plugin</bitbar.desc>
# <bitbar.image>https://imgur.com/0Ym6xNC</birtbar.image>
# <bitbar.dependencies></bitbar.dependencies>
# Hack for language not being set properly and unicode support
export LANG="${LANG:-en_US.UTF-8}"
PREFIX=""
APPENDIX=""
# user clicks on 'encoding'
if [[ "$1" = "encode" ]]; then
echo -n "$(echo -n "${PREFIX}$(pbpaste)${APPENDIX}" | base64)" | pbcopy
osascript -e "display notification \"Clipboard entry encoded with BASE64\" with title \"BitBar Clipboard BASE64-Encoder\"" &> /dev/null
exit
fi
if [[ "$1" = "decode" ]]; then
echo -n "$(echo -n "${PREFIX}$(pbpaste)${APPENDIX}" | base64 -D)" | pbcopy
osascript -e "display notification \"Clipboard entry decoded with BASE64\" with title \"BitBar Clipboard BASE64-Encoder\"" &> /dev/null
exit
fi
# Print icon
echo "🔏"
echo "---"
echo "Encode clipboard item with BASE64 | bash='$0' param1=encode terminal=false"
echo "Decode clipboard item with BASE64 | bash='$0' param1=decode terminal=false"