-
Notifications
You must be signed in to change notification settings - Fork 44
/
zshrun
executable file
·32 lines (27 loc) · 860 Bytes
/
zshrun
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
#!/bin/sh
# Invoke a Terminal.app window and block until it closes
#
# Uses the ZSHRUN flag and some Applescript to auto-close after invoking
# a command.
#
# One possible use is to invoke this from Qutebrowser, use a CLI password
# manager, then echo the result back into the Qutebrowser FIFO so the password
# appears in the HTML <input> field.
main() {
# 'tell application "Safari" to return URL of the front document' \
DOMAIN=$(osascript -e \
'tell application "Google Chrome" to return URL of active tab of first window' \
| awk -F/ '{ print $3 }' \
| awk -F. '{ print $(NF - 1) "." $NF }')
DOMAIN="$DOMAIN" ZSHRUN=1 osascript <<END
tell app "Terminal"
if not (exists window 1) then reopen
activate
repeat until (not exists window 1)
delay 0.5
end repeat
quit
end tell
END
}
main "$@"