diff --git a/README.md b/README.md index 8206aba..286d0fe 100644 --- a/README.md +++ b/README.md @@ -89,12 +89,14 @@ script! * install latest long term support version of node * npm packages: * yarn - * create-react-app - * prettier - * javascript-typescript-langserver - * babel - * eslint ### macOS settings configuration -something about settings \ No newline at end of file +Many macOS settings are not available through the UI, and many of the default +settings aren't chosen with professionals in mind. The script will interactively +take you through a series of questions related to these more esoteric macOS +settings (like always showing a file extension in Finder). + +There is an option to say `yes` once and not get the settings interactively, but +we would advise you read through `macos_settings.sh` to understand what you're +getting yourself into before choosing that option. \ No newline at end of file diff --git a/design_setup.sh b/design_setup.sh old mode 100644 new mode 100755 index af447d7..6a97bb8 --- a/design_setup.sh +++ b/design_setup.sh @@ -1,3 +1,5 @@ #!/bin/sh -brew install adobe-creative-cloud --cask \ No newline at end of file +brew bundle --file=- <<-EOS +cask "adobe-creative-cloud" +EOS \ No newline at end of file diff --git a/dev_setup.sh b/dev_setup.sh old mode 100644 new mode 100755 index 6a51e1e..a7c4a78 --- a/dev_setup.sh +++ b/dev_setup.sh @@ -4,15 +4,6 @@ brew bundle -if [ ! -d $HOME/.nvm ]; then - fancy_echo "NVM not found, installing" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash -else - fancy_echo "NVM found, continuing" -fi - -nvim install latest - if [ ! -d $HOME/.rvm ]; then fancy_echo "RVM not found, installing" \curl -sSL https://get.rvm.io | bash -s stable @@ -31,5 +22,16 @@ else rvm install 3.0.0 fi -fancy_echo "Installing common npm packages" -npm install -g yarn create-react-app prettier javascript-typescript-langserver babel eslint \ No newline at end of file +# installing rvm will create shell profiles if they do not exist +if [ ! -d $HOME/.nvm ]; then + fancy_echo "NVM not found, installing" + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | zsh + source ~/.zshrc +else + fancy_echo "NVM found, continuing" +fi + +nvm install --lts + +fancy_echo "Installing yarn" +npm install -g yarn diff --git a/macos_settings.sh b/macos_settings.sh new file mode 100755 index 0000000..002205d --- /dev/null +++ b/macos_settings.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +clear_and_header() { + clear + echo "" + echo "=============== macOS config wizard ================" + echo "( please choose each setting with either 'y' or 'n')" + echo "" +} + +# arguments: prompt, command +prompt_and_read() { + if [ "$ACCEPT_ALL" = "true" ]; then + eval "$2" + else + clear_and_header + echo "" + echo $1 + read macos + if [ "$macos" = "y" ]; then + eval "$2" + fi + fi +} + +echo "Please enter your admin password to update preferences" +sudo -v + +# Close any open System Preferences panes, to prevent them from overriding +# settings we’re about to change +osascript -e 'tell application "System Preferences" to quit' + +clear_and_header +echo "Accept all suggested options?" +read macos +if [ "$macos" = "y" ]; then + ACCEPT_ALL="true" +fi + +prompt_and_read "Hide all desktop icons?" \ + "defaults write com.apple.finder CreateDesktop false" + +prompt_and_read "Prevent photos from opening automatically when devices are plugged in?" \ + "defaults -currentHost write com.apple.ImageCapture disableHotPlug -bool true" + +prompt_and_read "Disable sound effects on boot?" \ + "sudo nvram SystemAudioVolume=\" \"" + +prompt_and_read "Disable autocorrect when typing?" \ + "defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false" + +prompt_and_read "Disable automatic capitalization?" \ + "defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool false" + +prompt_and_read "Disable automatic smart dashes?" \ + "defaults write NSGlobalDomain NSAutomaticDashSubstitutionEnabled -bool false" + +prompt_and_read "Disable automatic smart quotes?" \ + "defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool false" + +prompt_and_read "Disable the 'are you sure you want to open this application?' dialog?" \ + "defaults write com.apple.LaunchServices LSQuarantine -bool false" + +prompt_and_read "Show hidden files in finder?" \ + "defaults write com.apple.finder AppleShowAllFiles -bool true" + +prompt_and_read "Show file extensions in finder?" \ + "defaults write NSGlobalDomain AppleShowAllExtensions -bool true" + +prompt_and_read "Disable shadows in screenshots?" \ + "defaults write com.apple.screencapture disable-shadow -bool true" + +prompt_and_read "Enable subpixel font rendering on non-Apple displays?" \ + "defaults write NSGlobalDomain AppleFontSmoothing -int 2" + +prompt_and_read "Avoid creating .DS_Store files on network or USB volumes?" \ + "defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true && defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true" + +prompt_and_read "Automatically hide and show the Dock?" \ + "defaults write com.apple.dock autohide -bool true" + +prompt_and_read "Keep folders on top while sorting by name in finder?" \ + "defaults write com.apple.finder _FXSortFoldersFirst -bool true" + +prompt_and_read "Have the dock show only active applications?" \ + "defaults write com.apple.dock static-only -bool true; killall Dock" + +prompt_and_read "Visualize CPU usage in the Activity Monitor Dock icon" \ + "defaults write com.apple.ActivityMonitor IconType -int 5" + +prompt_and_read "Activity Monitor show all processes?" \ + "defaults write com.apple.ActivityMonitor ShowCategory -int 0" + +prompt_and_read "Save to disk (not iCloud) by default?" \ + "defaults write NSGlobalDomain NSDocumentSaveNewDocumentsToCloud -bool false" + +prompt_and_read "Expand save panel by default?" \ + "defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode -bool true && defaults write NSGlobalDomain NSNavPanelExpandedStateForSaveMode2 -bool true" + +prompt_and_read "Sort activity monitor results by CPU usage?" \ + "defaults write com.apple.ActivityMonitor SortColumn -string \"CPUUsage\" && defaults write com.apple.ActivityMonitor SortDirection -int 0" + +prompt_and_read "Add Rectangle as login item?" \ + "osascript -e 'tell application \"System Events\" to make login item at end with properties {name: \"Rectangle\",path:\"/Applications/Rectangle.app\", hidden:false}'" + +prompt_and_read "Add Alfred as login item?" \ + "osascript -e 'tell application \"System Events\" to make login item at end with properties {name: \"Alfred 4\",path:\"/Applications/Alfred 4.app\", hidden:false}'" + +prompt_and_read "Disable the warning when changing a file extension?" \ + "defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false" + +prompt_and_read "Show the ~/Library folder by default?" \ + "chflags nohidden ~/Library" + +prompt_and_read "Disable Resume system wide?" \ + "defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false" + +prompt_and_read "Save screenshots to their own folder on the Desktop?" \ + "mkdir $HOME/Desktop/screenshots && defaults write com.apple.screencapture location -string \"${HOME}/Desktop/screenshots\"" + +prompt_and_read "In Finder, search the current directory by default?" \ + "defaults write com.apple.finder FXDefaultSearchScope -string \"SCcf\"" + +for app in "Calendar" "Contacts" "Dock" "Finder" "SystemUIServer"; do + killall "$app" &> /dev/null +done diff --git a/setup_script.sh b/setup_script.sh old mode 100644 new mode 100755 index bc073ce..60675db --- a/setup_script.sh +++ b/setup_script.sh @@ -38,16 +38,98 @@ fi # Why do we install it for everyone? # It's the program that much more of this script relies on # -if [ ! -f /usr/local/bin/brew ]; then +# set expected Homebrew install dir by processor architecture +case $(arch) in + 'arm64') + BREW_DIR=/opt/homebrew/bin + ;; + 'x86_64') + BREW_DIR=/usr/local/bin + ;; + *) + unset BREW_DIR + ;; +esac + +if ! [[ -z "$BREW_DIR" ]] && ! [[ -f $BREW_DIR/brew ]]; then fancy_echo "Homebrew not found.. installing Homebrew" - /bin/zsh -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" -else + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + if [[ $BREW_DIR == /opt/homebrew/bin ]]; then + echo '# Set PATH, MANPATH, etc., for Homebrew.' >> ~/.zprofile + echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile + eval "$(/opt/homebrew/bin/brew shellenv)" + fancy_echo "brew added to PATH" + fi + brew -v +elif ! [[ -z "$BREW_DIR" ]] && [[ $(which brew) == $BREW_DIR/brew ]]; then fancy_echo "Homebrew detected" fancy_echo "Updating brew" brew update + brew -v +else + unset BREW_DIR + fancy_echo "No action taken for Homebrew; path did not match CPU architecture" fi -brew install google-chrome slack rectangle 1password spotify figma alfred --cask +if [[ -z "$BREW_DIR" ]]; then + fancy_echo "Skipping all Homebrew managed applications..." +else + if [ ! -d /Applications/"Google Chrome.app" ]; then + fancy_echo "Google Chrome not found.. installing Google Chrome" + brew install --cask google-chrome + else + fancy_echo "Google Chrome detected" + fancy_echo "Skipping Google Chrome..." + fi + + if [ ! -d /Applications/Slack.app ]; then + fancy_echo "Slack not found.. installing Slack" + brew install --cask slack + else + fancy_echo "Slack detected" + fancy_echo "Skipping Slack..." + fi + + if [ ! -d /Applications/Rectangle.app ]; then + fancy_echo "Rectangle not found.. installing Rectangle" + brew install --cask rectangle + else + fancy_echo "Rectangle detected" + fancy_echo "Skipping Rectangle..." + fi + + if [ ! -d /Applications/'1Password 7.app' ]; then + fancy_echo "1password not found.. installing 1password" + brew install --cask 1password + else + fancy_echo "1password detected" + fancy_echo "Skipping 1password..." + fi + + if [[ -d /Applications/'Spotify.app' ]] || [[ -d "$HOME/Applications/Chrome Apps.localized/Spotify.app" ]]; then + fancy_echo "Spotify detected" + fancy_echo "Skipping Spotify..." + else + fancy_echo "Spotify not found.. installing Spotify" + brew install --cask spotify + fi + + if [ ! -d /Applications/'Figma.app' ]; then + fancy_echo "Figma not found.. installing Figma" + brew install --cask figma + else + fancy_echo "Figma detected" + fancy_echo "Skipping Figma..." + fi + + if [ ! -d /Applications/'Alfred 4.app' ]; then + fancy_echo "Alfred not found.. installing Alfred" + brew install --cask alfred + else + fancy_echo "Alfred detected" + fancy_echo "Skipping Alfred..." + fi +fi if [ ! -f ./setup_script.sh ]; then git clone https://github.com/madeintandem/SetupScript.git $HOME/tandem_setup_script @@ -82,6 +164,22 @@ elif [ "$dev" = "y" ]; then . ./dev_setup.sh fi +############################# +# Useful macOS settings # +############################# +# Some settings and configuration of macOS are not accessible +# through the UI. Included here are some useful settings that +# can be opted into. + +fancy_echo "Would you like to set up some macOS configuration? y / n" +read macos + +if [ "$macos" = "y" ] && [ "$IS_CLONED" = "true" ]; then + . $HOME/tandem_setup_script/macos_settings.sh +elif [ "$macos" = "y" ]; then + . ./macos_settings.sh +fi + # clean up after yourself! if [ "$IS_CLONED" = "true" ]; then rm -rf $HOME/tandem_setup_script