Skip to content

Commit f3f1961

Browse files
Merge pull request #960 from ystknsh/master
add sh file, commands/browsing/open-multiple-websites-on-safari.template.sh
2 parents b38d4a7 + f379cbf commit f3f1961

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Required parameters:
4+
# @raycast.schemaVersion 1
5+
# @raycast.title Open Multiple Websites on Safari
6+
# @raycast.mode silent
7+
8+
# Optional parameters:
9+
# @raycast.icon 📚
10+
# @raycast.packageName Browsing
11+
12+
# Documentation:
13+
# @raycast.description Open multiple websites on Safari using list of URLs
14+
# @raycast.author Yasutaka Nishii
15+
# @raycast.authorURL https://github.com/ystknsh
16+
17+
# Set list of URLs
18+
urls=(
19+
"https://example.com"
20+
"https://example.org"
21+
"https://example.net"
22+
"https://example.jp"
23+
"https://example.io"
24+
"https://example.ai"
25+
)
26+
27+
# Make AppleScript commands
28+
applescript_command="tell application \"Safari\"
29+
make new document with properties {URL:\"${urls[0]}\"}
30+
tell window 1"
31+
32+
for ((i=1; i<${#urls[@]}; i++)); do
33+
applescript_command+="
34+
make new tab with properties {URL:\"${urls[$i]}\"}"
35+
done
36+
37+
applescript_command+="
38+
end tell
39+
end tell"
40+
41+
# Execute AppleScript
42+
osascript -e "$applescript_command"
43+
44+
# Set Safari window to front(Optional)
45+
osascript <<EOD
46+
tell application "System Events"
47+
tell process "Safari"
48+
set frontmost to true
49+
tell window 1
50+
set value of attribute "AXMain" to true
51+
set value of attribute "AXFocused" to true
52+
end tell
53+
end tell
54+
end tell
55+
EOD

0 commit comments

Comments
 (0)