Skip to content

Instantly share code, notes, and snippets.

@varunyellina
Last active April 24, 2024 10:20
Show Gist options
  • Save varunyellina/f1e018e8786478465ad1 to your computer and use it in GitHub Desktop.
Save varunyellina/f1e018e8786478465ad1 to your computer and use it in GitHub Desktop.
Install Xcode Command Line Tools, use Homebrew to install drivers, tools, apps and fonts on macOS
#!/bin/sh
# Scroll to bottom of this file to comment out sections that you don't need.
# This script exits whenever a particular tool / app / driver installation gives an error.
# Do watch out for apps that need you to open the installer from Homebrew's cache i.e Cellar. Ex: Little Snitch
########################
# Script Functions - Will be called later in the script
########################
function separator() {
printf %"$(tput cols)"s |tr " " "="
printf "\n"
}
function install_command_line_tools() {
if ! [ $(xcode-select -p) ]; then
echo "Xcode Command Line Tools is not installed, installing now ..."
xcode-select --install
sudo xcodebuild -license accept
else
echo "Xcode Command Line Tools is already installed, skipping ..."
fi
separator
sleep 1
}
function install_ohmyzsh() {
if [ -d ~/.oh-my-zsh ]; then
echo "oh-my-zsh is already installed, skipping ..."
else
echo "oh-my-zsh is not installed, installing now ..."
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
separator
sleep 1
}
function install_rosetta2() {
if [[ "$(sysctl -n machdep.cpu.brand_string)" == *'Apple'* ]]; then
if arch -x86_64 /usr/bin/true 2> /dev/null; then
echo "Rosetta 2 is already installed, skipping ..."
else
echo "Rosetta 2 is not installed, installing now ..."
softwareupdate --install-rosetta --agree-to-license
fi
fi
separator
sleep 1
}
function install_homebrew() {
if test ! $(which brew); then
echo "Homebrew is not installed, installing now ..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "Updating .zprofile ..."
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> $HOME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
else
echo "Homebrew is already installed, skipping ..."
fi
separator
sleep 1
}
function brew_tap_repositories() {
echo "Tapping Homebrew Repositories..."
for repo in "${REPOS[@]}"
do
brew tap $repo
done
separator
sleep 1
}
function install_mac_appstore_apps() {
# Install "mas" from Homebrew
if !(which mas > /dev/null 2>&1) then
brew install mas
fi
echo "Checking for App Store login..."
if !(mas account > /dev/null 2>&1) then
echo "Please login with your Apple ID to install apps from the App Store."
echo "Choose an option:"
select option in "Yes, install" "No, skip"; do
case $option in
"Yes, install" )
echo "Installing apps from App Store..."
mas install ${MASAPPS[@]}
echo "Updating existing apps from App Store..."
mas upgrade
return 1;;
"No, skip" )
echo "Skipping apps from App Store."
return 1;;
esac
done
else
echo "Installing apps from App Store..."
mas install ${MASAPPS[@]}
echo "Updating existing apps from App Store..."
mas upgrade
fi
separator
sleep 1
}
########################
# Homebrew repositories
########################
REPOS=(
homebrew/cask-fonts
homebrew/cask-versions
#varunyellina/homebrew-casks-old
)
########################
# Tools that can be installed with Homebrew
########################
TOOLS=(
ack
curl
git
htop
psgrep
ssh-copy-id
wget
imagemagick
)
########################
# Apps from Homebrew Cask
########################
APPS=(
## communication
#mailmate
thunderbird
protonmail-bridge
telegram
whatsapp
slack
#notion-calendar
## design
affinity-designer
affinity-photo
affinity-publisher
figma
#sketch
rive
imageoptim
## browsers & tools
arc
firefox
#google-chrome
#transmission
#browserosaurus
#velja - from Mac app store
resilio-sync
## documents handling & storage
adobe-acrobat-reader
microsoft-office
pdf-expert
google-drive
proton-drive
#dropbox
#arq
## security tools
protonvpn
blockblock
knockknock
#little-snitch
oversight
#do-not-disturb
## tools & utilities
appcleaner
#airfoil
#alfred
android-file-transfer
#anvil
bartender
#caffeine
#carbon-copy-cloner
#keka
lulu
raycast
#rectangle
vlc
## dev tools
android-platform-tools
android-studio
#docker
fork
iterm2
#kaleidoscope
sublime-text
sublime-merge
visual-studio-code
#postman
## virtualisation
#onyx
#utm
#vmware-fusion
## Quicklook plugins
#suspicious-package
#quicklookase
#qlvideo
#qlimagesize
#quicklook-json
#qlmarkdown
#qlstephen
)
########################
# Apps to modify hardware functionality
########################
HARDWARE_APPS=(
monitorcontrol
scroll-reverser
logitech-g-hub
logitech-camera-settings
logitech-options
)
########################
# Apps from App Store
########################
MASAPPS=(
## Apps
1352778147 # Bitwarden
#1166066070 # Bumpr
#1444383602 # Goodnotes 5
#1233368267 # Linea Link
#441258766 # Magnet
1464122853 # Nextdns
445189367 # Popclip
1607635845 # Velja
#497799835 # Xcode
889428659 # xScope
)
########################
# Fonts
########################
FONTS=(
font-monoid
font-source-code-pro
font-menlo-for-powerline
font-fira-code
)
########################
# You can enable and disable some sections of this script here.
# Do note that some are dependant on the others for proper installation.
########################
# Install Xcode Command Line Tools.
install_command_line_tools
# Install Rosetta 2 on Apple Silicon Macs to run x86 apps.
install_rosetta2
# Install Ohmyzsh shell prompt
install_ohmyzsh
# Install Homebrew
install_homebrew
# Tap various Repositories for additional tools and casks. These are required for some of the following steps.
brew_tap_repositories
# Install Tools
echo "Installing Tools..."
#brew install ${TOOLS[@]}
for tools in "${TOOLS[@]}"
do
brew install "$tools"
if [ $? -ne 0 ]
then
echo "\xE2\x9C\x98 Error encountered with installing: $tools"
fi
done
separator
# Install apps
echo "Installing Apps..."
for software in "${APPS[@]}"
do
brew install "$software"
if [ $? -ne 0 ]
then
echo "\xE2\x9C\x98 Error encountered with installing: $software"
fi
done
separator
# Install apps
echo "Installing Hardware Apps..."
for hsoftware in "${HARDWARE_APPS[@]}"
do
brew install "$hsoftware"
if [ $? -ne 0 ]
then
echo "\xE2\x9C\x98 Error encountered with installing: $hsoftware"
fi
done
separator
# Install apps from App Store
install_mac_appstore_apps
# Install Fonts
echo "Installing Fonts..."
for font in "${FONTS[@]}"
do
brew install "$font"
if [ $? -ne 0 ]
then
echo "\xE2\x9C\x98 Error encountered with installing: $font"
fi
done
separator
@lum7671
Copy link

lum7671 commented Jul 20, 2017

유용하겠네요. fork 해 갑니다. 혹시 문제 있으시면 말씀 부탁드립니다~ 고맙습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment