-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·82 lines (58 loc) · 1.88 KB
/
install
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
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env zsh
# -----------------------------------------------------------------------
# Pinboard.zsh installer
# -----------------------------------------------------------------------
print "pinboard> Installing bin..."
## Install to local bin directory ---------------------------------------
SRC=$(pwd)/pinboard
BIN_DIR=(
$HOME/.bin
$HOME/.local/bin
/usr/local/bin
)
for d in $BIN_DIR; do
# Select the first dir that is r/w
[[ -z "$DEST" ]] && test -w $d && DEST="$d/pinboard"
done
chmod +x $SRC
[[ -e $DEST ]] && rm $DEST
cp $SRC $DEST
[[ ! -x $DEST ]] && \
echo "pinboard> ERROR: failed to install bin to $DEST" && exit
echo "pinboard> Done. Copied to:
$DEST
"
## Install as Qutebrowser userscript -----------------------------------
print "pinboard> Installing as Qutebrowser userscript..."
QUTE_DEST="$HOME/.local/share/qutebrowser/userscripts/pinboard"
[[ -e $QUTE_DEST ]] && rm $QUTE_DEST
ln -sf $DEST $QUTE_DEST
echo "pinboard> Done. Linked bin from $DEST to:
$QUTE_DEST
"
## Prompt user for API token -------------------------------------------
BROWSERS=(
$BROWSER
qutebrowser
chromium
google-chrome-unstable
google-chrome-canary
google-chrome-dev
google-chrome
firefox
)
for b in $BROWSERS; do
# Select the first browser found
[[ -z "$BROWSER" ]] && test -x $b && BROWSER=$b
done
API_TOKEN_URL="https://pinboard.in/settings/password"
print "pinboard> Note: you must export your Pinboard API token in your shell:
export PINBOARD_API_TOKEN=<api_token>
The API token can be found in your Pinboard settings at
$API_TOKEN_URL
"
vared -p "What would you like to open this URL in $BROWSER? [y/N] " -c openBrowser
[[ $openBrowser =~ "(y|yes|Y|YES)" ]] && \
print "pinboard> Opening $API_TOKEN_URL in $BROWSER...." && \
$BROWSER $API_TOKEN_URL
print "pinboard> Installation complete. Exiting..."