-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewapp.sh
42 lines (41 loc) · 1.87 KB
/
newapp.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
newapp() {
# Usage: newapp app url profile_email
#
# Creates a barebones mac which wraps a website.
# The app will be indexed in spotlight for easy access.
#
# The script also opens vim to edit the script that will be
# run when the app is launched. This can be changed to have
# the app do something other than open a webpage as an app
# in Chrome, or it can be left alone by typing the three
# keys "colon", "q", and "enter".
#
# Arguments:
# app:
# The name of the app. The script will create a directory
# with this name in the current directory, and the script
# will be accessible in spotlight under this name.
# url:
# The url that serves as the homepage of the app.
# profile_email:
# The Chrome profile email address to use. Optional.
local appdir="${1//"'"/}"
local appdir="${appdir:-test}.app"
local url="${2//"'"/}"
local url="${url:-https://example.com}"
local profile_email="${3//"'"/}"
local contents="$appdir/Contents"
local macos="$contents/MacOS"
local script="$macos/script"
if [ -e "$appdir" ]; then
echo "whoops: $appdir exists"
return
fi
mkdir -p "$macos"
echo '<plist version="1.0"><dict><key>CFBundleExecutable</key><string>script</string></dict></plist>' > "$contents/Info.plist"
echo '#!/bin/bash' >"$script"
echo "open -n -a 'Google Chrome' --args --profile-email='$profile_email' --app='$url'" >>"$script"
chmod +x "$script"
vim "$script"
mdimport "$appdir"
}