Last active
July 17, 2024 17:10
-
-
Save vitorcalvi/7be5b480dd57e8228b713c0f882eb298 to your computer and use it in GitHub Desktop.
Comprehensive Bash script to automate macOS developer setup: installs essential apps with Homebrew, sets up Zsh with Oh My Zsh and Powerlevel10k, downloads FlutterFlow, updates /etc/hosts, sets up a conda environment, and installs Anaconda.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
# Function to install Xcode Command Line Tools | |
install_xcode_cli() { | |
echo "Installing Xcode Command Line Tools..." | |
xcode-select --install | |
} | |
# Function to install NVM, Node.js, and Yarn | |
install_nvm_node_yarn() { | |
echo "Installing NVM, Node.js, and Yarn..." | |
brew install nvm | |
mkdir -p ~/.nvm | |
echo 'export NVM_DIR=~/.nvm' >> ~/.zshrc | |
echo '[ -s "$(brew --prefix nvm)/nvm.sh" ] && . "$(brew --prefix nvm)/nvm.sh"' >> ~/.zshrc | |
source ~/.zshrc | |
nvm install --lts | |
brew install yarn | |
if brew list node &>/dev/null; then | |
brew uninstall node --ignore-dependencies | |
fi | |
ln -s ~/.nvm/versions/node/$(nvm current) /usr/local/Cellar/node | |
brew doctor | |
} | |
# Function to install applications using Homebrew Cask | |
install_apps_brew() { | |
echo "Installing applications using Homebrew Cask..." | |
brew install --cask macs-fan-control whatsapp | |
brew install wget | |
brew install --cask discord jandi firefox | |
brew install --cask android-file-transfer balenaetcher flutter visual-studio-code lmms sublime-text | |
brew install azure-cli python-tk | |
brew install --cask android-studio rectangle iterm2 | |
brew install --cask android-platform-tools tradingview | |
brew install --cask transmission | |
brew tap osrf/simulation | |
brew install gazebo11 | |
brew install scrcpy | |
brew install --cask flutter | |
} | |
# Function to set up Zsh and Oh My Zsh with Powerlevel10k | |
setup_zsh() { | |
echo "Setting up Zsh and Oh My Zsh..." | |
chsh -s "$(which zsh)" | |
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
mkdir -p "$HOME/.zsh" | |
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$HOME/.zsh/powerlevel10k" | |
echo 'source "$HOME/.zsh/powerlevel10k/powerlevel10k.zsh-theme"' >> "$HOME/.zshrc" | |
echo "Please restart your shell or run 'source $HOME/.zshrc' to apply changes." | |
} | |
# Function to download and install applications that are not available via Homebrew Cask | |
download_apps_no_brew() { | |
echo "Downloading and installing FlutterFlow..." | |
curl -o "$HOME/Downloads/flutterflow-latest-macos.dmg" https://storage.googleapis.com/flutterflow-downloads/macos/flutterflow-latest-macos.dmg | |
hdiutil attach "$HOME/Downloads/flutterflow-latest-macos.dmg" | |
cp -R "/Volumes/FlutterFlow/FlutterFlow.app" "/Applications/" | |
hdiutil detach "/Volumes/FlutterFlow" | |
echo "Downloading and installing ChatGPT..." | |
curl -o "$HOME/Downloads/chatgpt-latest-macos.dmg" https://openai.com/chatgpt/download/ | |
hdiutil attach "$HOME/Downloads/chatgpt-latest-macos.dmg" | |
cp -R "/Volumes/ChatGPT/ChatGPT.app" "/Applications/" | |
hdiutil detach "/Volumes/ChatGPT" | |
echo "Downloading and installing Jan.ai..." | |
curl -o "$HOME/Downloads/jan-ai-latest-macos.dmg" https://jan.ai/download/ | |
hdiutil attach "$HOME/Downloads/jan-ai-latest-macos.dmg" | |
cp -R "/Volumes/Jan.ai/Jan.ai.app" "/Applications/" | |
hdiutil detach "/Volumes/Jan.ai" | |
} | |
# Function to update /etc/hosts file with predefined IP-hostname pairs | |
update_hosts_file() { | |
echo "Updating /etc/hosts file..." | |
local local_pairs=() | |
local_pairs+=("192.168.1.36 ollama") | |
local_pairs+=("192.168.31.10 cyber") | |
local_pairs+=("192.168.31.184 neurosity") | |
local_pairs+=("192.168.31.8 pico") | |
for pair in "${local_pairs[@]}"; do | |
local IP=$(echo "$pair" | cut -d ' ' -f 1) | |
local HOSTNAME=$(echo "$pair" | cut -d ' ' -f 2) | |
local ENTRY="$IP $HOSTNAME" | |
grep -qF "$ENTRY" /etc/hosts || echo "$ENTRY" | sudo tee -a /etc/hosts > /dev/null | |
done | |
} | |
# Function to set up conda environment and install required packages | |
install_macMetal() { | |
echo "Setting up conda environment and installing required packages..." | |
source "$HOME/.zshrc" | |
conda create --name macMetal python=3.10 -y | |
source "$(conda info --base)/etc/profile.d/conda.sh" | |
conda activate macMetal | |
conda install -c apple tensorflow-deps -y | |
pip install tensorflow-macos tensorflow-metal | |
conda install notebook -y | |
pip install numpy<2.0.0 pandas matplotlib scikit-learn scipy plotly jupyterlab<4.1 | |
pip install chardet | |
mkdir -p "$HOME/Desktop/JupyterNotebooks" | |
} | |
# Function to install Anaconda | |
installAnaconda() { | |
echo "Installing Anaconda..." | |
brew install --cask anaconda | |
echo 'export PATH="/opt/homebrew/anaconda3/bin:$PATH"' >> "$HOME/.zshrc" | |
sudo chown -R "$USER" "$HOME/.conda" | |
echo "Please restart your shell or run 'source $HOME/.zshrc' to apply changes." | |
} | |
# Main function to execute all steps | |
main() { | |
install_xcode_cli | |
install_nvm_node_yarn | |
install_apps_brew | |
download_apps_no_brew | |
update_hosts_file | |
installAnaconda | |
install_macMetal | |
setup_zsh | |
echo "Setup complete!" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment