-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmas.zsh
51 lines (44 loc) · 1.03 KB
/
mas.zsh
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
#!/usr/bin/env zsh
source ./util.zsh
# Require `mas` command to execute this.
function has_app() {
local app_id=$1
mas list | grep -q "^$app_id"
return $?
}
UNINSTALL_APPS=(
408981434 # iMovie
682658836 # GarageBand
)
echo "=== Uninstall some default apps"
for app_id in "${UNINSTALL_APPS[@]}"; do
if has_app $app_id; then
print_uninstall_msg "ID: $app_id"
sudo mas uninstall "$app_id"
if [[ $? -eq 0 ]]; then
print_success_msg "Uninstalled ID: $app_id"
else
print_failed_msg "Failed to uninstall ID: $app_id"
fi
else
print_skip_msg "ID: $app_id is already uninstalled"
fi
done
INSTALL_APPS=(
539883307 # LINE
457622435 # Yoink
)
echo "=== Install my favorite apps"
for app_id in "${INSTALL_APPS[@]}"; do
if has_app $app_id; then
print_skip_msg "ID: $app_id "
else
print_install_msg "ID: $app_id"
mas install "$app_id"
if [[ $? -eq 0 ]]; then
print_success_msg "Installed ID: $app_id"
else
print_failed_msg "Failed to install ID: $app_id"
fi
fi
done