-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacos-setup.scpt
More file actions
166 lines (132 loc) · 5.99 KB
/
Copy pathmacos-setup.scpt
File metadata and controls
166 lines (132 loc) · 5.99 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
-- macOS Setup Script
-- Author: Ethan Blair
-- This script configures Finder/Dock preferences and installs Homebrew packages
-- Run with: osascript setup.scpt
on run
-- Display initial progress dialog
display dialog "Starting macOS setup configuration..." buttons {"OK"} default button "OK" with title "macOS Setup" with icon note
try
-- Configure Finder preferences
set progress total steps to 6
set progress completed steps to 0
set progress description to "Configuring Finder preferences..."
set progress additional description to "Setting up file extensions display..."
-- Show all file extensions in Finder
do shell script "defaults write NSGlobalDomain AppleShowAllExtensions -bool true"
-- Restart Finder to apply changes
do shell script "killall Finder"
set progress completed steps to 1
set progress additional description to "Finder preferences updated"
-- Configure Dock preferences
set progress description to "Configuring Dock preferences..."
set progress additional description to "Setting Dock size and autohide..."
-- Set Dock size to 48 pixels (reasonable default)
do shell script "defaults write com.apple.dock tilesize -int 48"
-- Enable Dock autohide
do shell script "defaults write com.apple.dock autohide -bool true"
-- Set faster autohide delay (0.2 seconds)
do shell script "defaults write com.apple.dock autohide-delay -float 0.2"
-- Set faster autohide animation (0.4 seconds)
do shell script "defaults write com.apple.dock autohide-time-modifier -float 0.4"
-- Restart Dock to apply changes
do shell script "killall Dock"
set progress completed steps to 2
set progress additional description to "Dock preferences updated"
-- Check if Homebrew exists
set progress description to "Checking for Homebrew..."
set progress additional description to "Looking for Homebrew installation..."
set homebrewExists to false
set homebrewPath to ""
try
-- Check common Homebrew locations
try
set homebrewPath to do shell script "/opt/homebrew/bin/brew --version 2>/dev/null && echo '/opt/homebrew/bin/brew' || echo ''"
if homebrewPath contains "/opt/homebrew/bin/brew" then
set homebrewExists to true
set homebrewPath to "/opt/homebrew/bin/brew"
end if
end try
if not homebrewExists then
try
set homebrewPath to do shell script "/usr/local/bin/brew --version 2>/dev/null && echo '/usr/local/bin/brew' || echo ''"
if homebrewPath contains "/usr/local/bin/brew" then
set homebrewExists to true
set homebrewPath to "/usr/local/bin/brew"
end if
end try
end if
if not homebrewExists then
try
set homebrewPath to do shell script "which brew 2>/dev/null || echo ''"
if homebrewPath is not "" then
set homebrewExists to true
end if
end try
end if
on error
set homebrewExists to false
end try
set progress completed steps to 3
if homebrewExists then
set progress additional description to "Homebrew found at: " & homebrewPath
-- Install packages if Homebrew exists
set progress description to "Installing Homebrew packages..."
-- Install Google Chrome
set progress additional description to "Installing Google Chrome..."
try
do shell script homebrewPath & " list --cask google-chrome >/dev/null 2>&1 || " & homebrewPath & " install --cask google-chrome"
set progress completed steps to 4
set progress additional description to "Google Chrome installation completed"
on error errMsg
display dialog "Warning: Failed to install Google Chrome: " & errMsg buttons {"Continue"} default button "Continue" with icon caution
set progress completed steps to 4
end try
-- Install iTerm2
set progress additional description to "Installing iTerm2..."
try
do shell script homebrewPath & " list --cask iterm2 >/dev/null 2>&1 || " & homebrewPath & " install --cask iterm2"
set progress completed steps to 5
set progress additional description to "iTerm2 installation completed"
on error errMsg
display dialog "Warning: Failed to install iTerm2: " & errMsg buttons {"Continue"} default button "Continue" with icon caution
set progress completed steps to 5
end try
-- Install Visual Studio Code
set progress additional description to "Installing Visual Studio Code..."
try
do shell script homebrewPath & " list --cask visual-studio-code >/dev/null 2>&1 || " & homebrewPath & " install --cask visual-studio-code"
set progress completed steps to 6
set progress additional description to "Visual Studio Code installation completed"
on error errMsg
display dialog "Warning: Failed to install Visual Studio Code: " & errMsg buttons {"Continue"} default button "Continue" with icon caution
set progress completed steps to 6
end try
else
set progress additional description to "Homebrew not found - skipping package installations"
set progress completed steps to 6
end if
-- Display final success message
if homebrewExists then
display dialog "macOS setup completed successfully!
Configured:
• Finder: Show all file extensions
• Dock: Size 48px, autohide enabled with fast animations
Homebrew packages installed:
• Google Chrome
• iTerm2
• Visual Studio Code
You may need to restart applications to see all changes." buttons {"OK"} default button "OK" with title "Setup Complete" with icon note
else
display dialog "macOS setup completed!
Configured:
• Finder: Show all file extensions
• Dock: Size 48px, autohide enabled with fast animations
Note: Homebrew was not found, so no packages were installed.
To install Homebrew, visit: https://brew.sh
You may need to restart applications to see all changes." buttons {"OK"} default button "OK" with title "Setup Complete" with icon note
end if
on error errMsg number errNum
-- Handle any errors
display dialog "Setup failed with error: " & errMsg & " (Error " & errNum & ")" buttons {"OK"} default button "OK" with title "Setup Error" with icon stop
end try
end run