Skip to content

Instantly share code, notes, and snippets.

@wyattowalsh
Last active January 24, 2025 13:24
Show Gist options
  • Save wyattowalsh/03cb9559dc981a69d410e3ff5ee085fb to your computer and use it in GitHub Desktop.
Save wyattowalsh/03cb9559dc981a69d410e3ff5ee085fb to your computer and use it in GitHub Desktop.
π™’π™–π™˜π™Šπ™Ž π–²π–Ύπ—π—Žπ—‰ π–²π–Όπ—‹π—‚π—‰π—π—Œ πŸ§‘β€πŸ­ βš™οΈ πŸ’»

πŸ–₯️ Configurable macOS Setup Scripts

Easily automate macOS environment setup with essential tools, applications, and Zsh customizations.

Designed to streamline macOS setup, this script suite leverages Homebrew for efficient package management, enhances Zsh with Oh My Zsh and Powerlevel10k, and customizes your development environment. Using setup_config.sh, you can effortlessly tailor the installation, benefit from detailed logging, and apply robust error handling for a smooth, reliable setup.


βš™ Default Setup Configuration ‡️

πŸ“œ Configuration Guide

  • PACKAGES: Define Homebrew formulae to install.
  • APPS: Add cask applications.
  • SHELL_CONFIGS: Customize your shell with exports, aliases, or other Zsh configurations.

πŸ“¦ Homebrew Packages

Package Description
docker-completion Command-line completion for Docker commands in zsh
docker-compose Tool for defining and running multi-container Docker applications
gcc GNU Compiler Collection, essential for compiling code from source
gh GitHub CLI for managing GitHub resources from the terminal
git Version control system for tracking code changes
graphviz Tool for creating visual representations of graphs and networks
java Java Development Kit for running Java applications
make Utility for building and managing code projects
nvm Node Version Manager for installing and managing multiple Node.js versions
poetry Python dependency management and packaging tool
pyenv Python Version Manager for managing multiple Python versions
rbenv Ruby Version Manager for managing multiple Ruby versions
ruby-build Add-on for rbenv that provides Ruby installation scripts
sphinx-doc Documentation generator, primarily for Python projects
speedtest-cli Command-line interface for testing internet speed
tree Directory listing tool that displays folder structure as a tree
unar Utility for extracting RAR archives and other compressed files
watchman Tool for watching files and recording changes, often used in development
wget Network utility to retrieve files from the web
zsh Z shell, an extended Bourne shell with features for interactive use
zsh-completions Additional completions for Z shell commands

πŸ–₯ Homebrew Cask Applications

App Description
db-browser-for-sqlite GUI browser for SQLite databases, useful for database management
docker Container platform for building, running, and managing containerized apps
glance A quick system monitor for macOS, displays resource usage
github desktop GitHub desktop application for managing GitHub repositories
google-chrome Popular web browser by Google
google-drive Google Drive desktop client for file storage and synchronization
iina Modern macOS media player with sleek interface and powerful features
jupyter-notebook-ql QuickLook extension for previewing Jupyter notebooks in Finder
logi-options-plus Logitech application for configuring peripherals
mark-text Markdown editor with a simple and intuitive interface
miniconda Distribution of Python and packages for data science and machine learning
notion All-in-one workspace for notes, tasks, and projects
obsidian Markdown-based knowledge base and note-taking app
qlmarkdown QuickLook plugin for previewing Markdown files in Finder
quicklook-csv QuickLook plugin for previewing CSV files in Finder
responsively Browser tailored for responsive web development
slack Collaboration and communication tool, popular for team chat
spotify Music streaming app with a vast library of songs
visual-studio-code Source code editor with support for debugging, syntax highlighting, etc.
webpquicklook QuickLook plugin for previewing WebP images in Finder
zotero Reference manager for managing and organizing research sources

🧰 Default Shell Configurations (SHELL_CONFIGS)

These default configurations include useful PATH exports, aliases, and environment setups to streamline your terminal experience:

  • Aliases:

    • brew: An override to avoid pyenv interference, ensuring Homebrew runs independently.
    • c: Clears the terminal screen for quick readability.
  • Path Exports:

    • HOMEBREW_PREFIX, PYENV_ROOT, and NVM_DIR are set up to simplify access to installed tools.
    • Custom directories for Homebrew packages like make, sphinx-doc, curl, and qt@5 are added to PATH.
  • Other Environment Configurations:

    • rbenv and pyenv are initialized if available, managing Ruby and Python versions for flexibility across projects.
    • Powerlevel10k theme for Zsh is sourced and set up, providing a powerful visual prompt with additional customization options.

Tip

To add or remove tools, simply update the PACKAGES and APPS arrays in setup_config.sh.


πŸ“‹ File Structure Overview

πŸ“ mac_setup/
β”œβ”€β”€ README.md                   # Documentation
β”œβ”€β”€ setup.zsh                   # Main setup script
β”œβ”€β”€ setup_config.sh             # Configurable package/app/shell settings
└── setup_functions.sh          # Core functions, error handling, logging

πŸš€ Quick Start

  1. Clone the Repository:

    git clone https://gist.github.com/03cb9559dc981a69d410e3ff5ee085fb.git mac_setup
    cd mac_setup
  2. Customize Your Setup:

    • Edit setup_config.sh to add or remove packages, apps, or shell configurations.
    • Review the default settings and adjust them to your needs.
  3. Make the Script Executable and Run It:

    chmod +x setup.zsh
  4. Run the Setup Script:

    • Default setup:
      ./setup.zsh
    • Verbose output:
      ./setup.zsh -v
    • Dry run (simulates setup without changes):
      ./setup.zsh -d

In one huge command:

cd && rm -rf mac_setup && git clone https://gist.github.com/03cb9559dc981a69d410e3ff5ee085fb.git mac_setup && cd mac_setup && chmod +x setup.zsh && ./setup.zsh -v
#!/usr/bin/env zsh
<<COMMENT
-------------------------------------------------
setup.zsh: A macOS configuration setup script
Purpose:
Automates the setup process for a new macOS machine by installing desired Homebrew packages, cask apps, and configuring zsh.
Usage Examples:
./setup.zsh : Run the setup
./setup.zsh -v : Run the setup with verbose output
./setup.zsh -d : Run a dry run with verbose output
./setup.zsh -s : Skip updating existing packages
./setup.zsh -h : Display help message
-------------------------------------------------
COMMENT
# Enforce strict error handling
set -euo pipefail
# Script version
readonly SCRIPT_VERSION="1.5.1"
# Config file path
readonly CONFIG_FILE="./setup_config.sh"
# Function to keep sudo alive
keep_sudo_alive() {
sudo -v
while true; do
sleep 60
sudo -n true 2>/dev/null || exit
kill -0 "$$" || exit
done &>/dev/null &
}
# Call the function at the start of the script
keep_sudo_alive
# Source functions
source "setup_functions.sh"
# Parse arguments
parse_arguments "$@"
# Load config
load_config "$CONFIG_FILE"
# Run main function
main
###################################################
# Configuration settings for setup.zsh
#
# Define the packages, applications, and shell configurations you want for your macOS setup.
###################################################
# Homebrew packages to install
PACKAGES=(
discord # discord chat server app
docker-completion # Command-line completion for Docker commands in zsh
docker-compose # Tool for defining and running multi-container Docker applications
gcc # GNU Compiler Collection, essential for compiling code from source
gh # GitHub CLI for managing GitHub resources from the terminal
git # Version control system for tracking code changes
graphviz # Tool for creating visual representations of graphs and networks
java # Java Development Kit for running Java applications
make # Utility for building and managing code projects
nvm # Node Version Manager for installing and managing multiple Node.js versions
poetry # Python dependency management and packaging tool
pyenv # Python Version Manager for managing multiple Python versions
r # R programming language and software environment for statistical computing
rbenv # Ruby Version Manager for managing multiple Ruby versions
ruby-build # Add-on for rbenv that provides ruby installation scripts
sphinx-doc # Documentation generator, primarily for Python projects
speedtest-cli # Command-line interface for testing internet speed
stripe/stripe-cli/stripe # Stripe CLI for managing Stripe resources from the terminal
tree # Directory listing tool that displays folder structure as a tree
unar # Utility for extracting RAR archives and other compressed files
uv # An extremely fast Python package and project manager, written in Rust.
watchman # Tool for watching files and recording changes, often used in development
wget # Network utility to retrieve files from the web
yarn # yarn for package mgmt
zsh # Z shell, an extended Bourne shell with features for interactive use
zsh-completions # Additional completions for Z shell commands
)
# Cask apps to install
APPS=(
db-browser-for-sqlite # GUI browser for SQLite databases, useful for database management
docker # Container platform for building, running, and managing containerized applications
glance # A quick system monitor for macOS, displays resource usage
github # GitHub desktop application for managing GitHub repositories
google-chrome # Popular web browser by Google
google-drive # Google Drive desktop client for file storage and synchronization
iina # Modern macOS media player with a sleek interface and powerful features
jupyter-notebook-ql # QuickLook extension for previewing Jupyter notebooks in Finder
logi-options+ # Logitech application for configuring Logitech peripherals
mark-text # Markdown editor with a simple and intuitive interface
miniconda # Distribution of Python and packages for data science and machine learning
notion # All-in-one workspace for notes, tasks, and projects
obsidian # Markdown-based knowledge base and note-taking app
qlmarkdown # QuickLook plugin for previewing Markdown files in Finder
quicklook-csv # QuickLook plugin for previewing CSV files in Finder
qview # Image viewer
responsively # Browser tailored for responsive web development
slack # Collaboration and communication tool, popular for team chat
spotify # Music streaming app with a vast library of songs
upscayl # AI image upscaling app
visual-studio-code # Source code editor with support for debugging, syntax highlighting, and more
webpquicklook # QuickLook plugin for previewing WebP images in Finder
zotero # Reference manager for managing and organizing research sources
# Font casks
font-sf-pro # San Francisco Pro font family by Apple
font-sf-compact # San Francisco Compact font family by Apple
font-sf-mono # San Francisco Mono font family by Apple
font-new-york # New York serif font family by Apple
font-fira-code # Monospaced font with programming ligatures
font-montserrat # Versatile sans-serif font
font-fontawesome # Iconic font and CSS toolkit
font-awesome-terminal-fonts # Awesome terminal fonts with icons
font-academicons # Font for academic-related icons
font-devicons # Font for development-related icons
font-foundation-icons # Foundation's icon font
font-material-design-icons-webfont # Material Design Icons in web font format
font-material-icons # Google's Material Icons font
font-mynaui-icons # Icon font for Mynaui projects
font-simple-line-icons # Minimal and elegant icon font
)
# PATH exports and other shell configurations
SHELL_CONFIGS=(
# Initialize Homebrew and set HOMEBREW_PREFIX
'if [ -x /opt/homebrew/bin/brew ]; then
eval "$(/opt/homebrew/bin/brew shellenv)"
elif [ -x /usr/local/bin/brew ]; then
eval "$(/usr/local/bin/brew shellenv)"
fi'
'export HOMEBREW_PREFIX="$(brew --prefix)"' # Define Homebrew prefix path for easier reference
# Ensure Homebrew bin is in PATH
'export PATH="$HOMEBREW_PREFIX/bin:$PATH"'
# Add GNU Make tools to PATH
'export PATH="$HOMEBREW_PREFIX/opt/make/libexec/gnubin:$PATH"'
# Initialize pyenv
'export PYENV_ROOT="$HOME/.pyenv"'
'export PATH="$PYENV_ROOT/bin:$PATH"'
'if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
fi'
# Initialize rbenv
'export PATH="$HOME/.rbenv/bin:$PATH"'
'if command -v rbenv 1>/dev/null 2>&1; then
eval "$(rbenv init - zsh)"
fi'
# Set up NVM
'export NVM_DIR="$HOME/.nvm"'
'[ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && . "$HOMEBREW_PREFIX/opt/nvm/nvm.sh"'
# Add other necessary paths
'export PATH="$HOMEBREW_PREFIX/opt/sphinx-doc/bin:$PATH"'
'export PATH="$HOMEBREW_PREFIX/opt/openjdk/bin:$PATH"'
'export PATH="$HOMEBREW_PREFIX/opt/curl/bin:$PATH"'
'export PATH="$HOMEBREW_PREFIX/opt/qt@5/bin:$PATH"'
# Compiler flags
'export CPPFLAGS="-I$HOMEBREW_PREFIX/opt/openjdk/include -I$HOMEBREW_PREFIX/opt/curl/include -I$HOMEBREW_PREFIX/opt/qt@5/include"'
'export LDFLAGS="-L$HOMEBREW_PREFIX/opt/curl/lib -L$HOMEBREW_PREFIX/opt/qt@5/lib"'
'export PKG_CONFIG_PATH="$HOMEBREW_PREFIX/opt/curl/lib/pkgconfig:$HOMEBREW_PREFIX/opt/qt@5/lib/pkgconfig"'
# Add custom Zsh function path
'fpath+=~/.zfunc'
# Aliases
'alias c="clear"'
# Source Powerlevel10k theme
'if [ -f "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k/powerlevel10k.zsh-theme" ]; then
source "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k/powerlevel10k.zsh-theme"
else
echo "Powerlevel10k theme not found at ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k/powerlevel10k.zsh-theme"
fi'
# Load Powerlevel10k configuration if it exists
'[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh'
)
#!/usr/bin/env zsh
###################################################
# Utility functions and core logic for setup.zsh
###################################################
# Enforce strict error handling
setopt ERR_EXIT NO_UNSET PIPE_FAIL
# Set Internal Field Separator
IFS=$'\n\t'
# Ensure VERBOSE has a default value
VERBOSE=${VERBOSE:-false}
# Modified error handling function
handle_error() {
local exit_code="$?"
local error_info="${funcfiletrace[1]:-}"
local error_file="${error_info%%:*}"
local error_line="${error_info##*:}"
local last_command="${funcstack[1]:-}"
log "An error occurred in function '${last_command:-main}' at ${error_file:-unknown}:$error_line. Exit code: $exit_code." "warning"
# Do not exit the script; continue execution
}
# Trap errors and handle them
trap 'handle_error' ERR
# Logging function with levels and colors
log() {
local message="$1"
local level="${2:-info}"
local color_code
case "$level" in
debug) color_code="34" ;; # Blue
info) color_code="32" ;; # Green
warning) color_code="33" ;; # Yellow
error) color_code="31" ;; # Red
*) color_code="0" ;; # Default
esac
if $VERBOSE || [[ "$level" != "debug" ]]; then
printf "\e[%sm[%s][%s] %s\e[0m\n" "$color_code" "$(date '+%Y-%m-%d %H:%M:%S')" "$level" "$message"
fi
}
# Check if a given command exists in the system
command_exists() {
command -v "$1" &> /dev/null
}
# Check if an application exists in the /Applications directory
app_exists() {
local app_name="$1"
# Ensure the app name is not empty
if [ -z "$app_name" ]; then
log "Error: app_exists function called with an empty app name." "error"
return 1
fi
# Check for both "AppName.app" and "AppName"
if [ -d "/Applications/$app_name.app" ] || [ -d "/Applications/$app_name" ]; then
return 0 # App exists
else
return 1 # App does not exist
fi
}
# Get application names from a cask (using jq for JSON parsing)
get_cask_app_name() {
local cask_name="$1"
brew info --cask --json=v2 "$cask_name" 2>/dev/null | jq -r '
.casks[0].artifacts[] |
if type=="object" then
.app[]?
elif type=="array" and .[0]=="app" then
.[1]
else
empty
end
'
}
# Check if a cask is installed via Homebrew
cask_installed() {
local cask_name="$1"
brew list --cask "$cask_name" &>/dev/null
}
# Parse command-line arguments and set flags
parse_arguments() {
VERBOSE=false
DRY_RUN=false
SKIP_UPDATES=false
while getopts ":vdsh" opt; do
case $opt in
v) VERBOSE=true ;;
d) DRY_RUN=true; VERBOSE=true ;;
s) SKIP_UPDATES=true ;;
h)
print_usage
exit 0
;;
\?)
log "Invalid option: -$OPTARG" "error"
print_usage
exit 1
;;
esac
done
}
# Print usage information
print_usage() {
echo "Usage: ./setup.zsh [options]"
echo "Options:"
echo " -v : Enable verbose output"
echo " -d : Dry run mode (no changes made)"
echo " -s : Skip updating existing packages"
echo " -h : Display this help message"
}
# Load the configuration file
load_config() {
local config_file="$1"
if [[ ! -f "$config_file" ]]; then
log "Configuration file not found: $config_file. Exiting." "error"
exit 1
else
source "$config_file"
fi
}
# Verify the script is being run on macOS
check_macos_compatibility() {
if [[ "$(uname)" != "Darwin" ]]; then
log "This script is intended for macOS only." "error"
exit 1
fi
local macos_version
macos_version=$(sw_vers -productVersion)
log "Detected macOS version: $macos_version"
local min_version="10.15"
if [[ "$(echo -e "$macos_version\n$min_version" | sort -V | head -n1)" != "$min_version" ]]; then
log "This script requires at least macOS $min_version. Detected version is $macos_version." "error"
exit 1
fi
}
# Check if the script is run as root (should not be)
check_user_privileges() {
if [[ "$EUID" -eq 0 ]]; then
log "This script should not be run as root. Please run as a regular user with sudo privileges when necessary." "error"
exit 1
fi
}
# Verify all dependencies are installed
check_dependencies() {
local dependencies=("curl" "git" "jq")
for dep in "${dependencies[@]}"; do
if ! command_exists "$dep"; then
log "Dependency $dep is missing."
if [[ "$dep" == "git" ]]; then
log "Attempting to install $dep via Xcode Command Line Tools..."
if ! $DRY_RUN; then
xcode-select --install || true
until command_exists git; do
sleep 5
done
else
log "[DRY-RUN] Would install $dep via Xcode Command Line Tools"
fi
elif [[ "$dep" == "jq" ]]; then
log "Installing $dep via Homebrew..."
if ! $DRY_RUN; then
brew install jq || {
log "Failed to install $dep. Please check your network connection." "error"
exit 1
}
else
log "[DRY-RUN] Would install $dep via Homebrew"
fi
else
log "Please install $dep and rerun the script." "error"
exit 1
fi
fi
done
}
# Check network connectivity
check_network_connectivity() {
if ! ping -c 1 -W 1 8.8.8.8 &>/dev/null; then
log "Network connectivity is required for this script. Please check your connection." "error"
exit 1
fi
}
# Install or upgrade a Homebrew formula or cask
install_or_upgrade_brew_item() {
local item="$1"
local is_cask="$2" # "cask" or "formula"
if [[ "$is_cask" == "cask" ]]; then
if cask_installed "$item"; then
log "Cask $item is already installed via Homebrew."
if ! $SKIP_UPDATES; then
if brew outdated --cask --quiet "$item" &>/dev/null; then
log "Cask $item is outdated. Upgrading..."
if ! $DRY_RUN; then
brew upgrade --cask "$item" || brew reinstall --cask "$item" || {
log "Failed to upgrade cask $item. Continuing to next item." "warning"
}
else
log "[DRY-RUN] Would upgrade/reinstall cask $item"
fi
else
log "Cask $item is up-to-date."
fi
else
log "Skipping update for cask $item due to --skip-updates flag."
fi
else
log "Installing cask: $item..."
if ! $DRY_RUN; then
brew install --cask "$item" || {
log "Failed to install cask $item. Continuing to next item." "warning"
}
else
log "[DRY-RUN] Would install cask $item"
fi
fi
else
# Handle formula installations
if brew list --formula --versions "$item" &>/dev/null; then
if ! $SKIP_UPDATES; then
if brew outdated --quiet "$item" &>/dev/null; then
log "Formula $item is outdated. Upgrading..."
if ! $DRY_RUN; then
brew upgrade "$item" || brew reinstall "$item" || {
log "Failed to upgrade formula $item. Continuing to next item." "warning"
}
else
log "[DRY-RUN] Would upgrade/reinstall formula $item"
fi
else
log "Formula $item is up-to-date."
fi
else
log "Skipping update for formula $item due to --skip-updates flag."
fi
else
log "Installing formula: $item..."
if ! $DRY_RUN; then
brew install "$item" || {
log "Failed to install formula $item. Continuing to next item." "warning"
}
else
log "[DRY-RUN] Would install formula $item"
fi
fi
fi
}
# Installs predefined packages and casks using Homebrew
install_brew_items() {
log "Installing Homebrew packages and casks..."
for pkg in "${PACKAGES[@]}"; do
install_or_upgrade_brew_item "$pkg" "formula"
done
for app in "${APPS[@]}"; do
install_or_upgrade_brew_item "$app" "cask"
done
}
# Installs Xcode Command Line Tools
install_xcode() {
if ! xcode-select --print-path &> /dev/null; then
log "Xcode Command Line Tools are not installed. Installing..."
if ! $DRY_RUN; then
xcode-select --install || true
until xcode-select --print-path &> /dev/null; do
sleep 5
done
else
log "[DRY-RUN] Would install Xcode Command Line Tools"
fi
else
log "Xcode Command Line Tools are already installed."
fi
}
# Installs Homebrew on macOS if not present
install_or_update_homebrew() {
if ! command_exists brew; then
log "Homebrew is not installed. Installing..."
if ! $DRY_RUN; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" || {
log "Homebrew installation failed. Please ensure you have sudo privileges." "error"
exit 1
}
eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv 2>/dev/null)"
else
log "[DRY-RUN] Would install Homebrew"
fi
else
if ! $SKIP_UPDATES; then
log "Updating Homebrew to the latest version..."
if ! $DRY_RUN; then
brew update
else
log "[DRY-RUN] Would update Homebrew"
fi
else
log "Skipping Homebrew update due to --skip-updates flag."
fi
fi
HOMEBREW_PREFIX="$(brew --prefix)"
}
# Installs Oh My Zsh shell framework
install_oh_my_zsh() {
if [[ ! -d "$HOME/.oh-my-zsh" ]]; then
log "Oh My Zsh is not installed. Installing..."
if ! $DRY_RUN; then
RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" || {
log "Failed to install Oh My Zsh. Please check your network connection." "error"
exit 1
}
else
log "[DRY-RUN] Would install Oh My Zsh"
fi
else
log "Oh My Zsh is already installed."
fi
}
# Installs Powerlevel10k Zsh theme
install_powerlevel10k() {
local theme_dir="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
if [[ ! -d "$theme_dir" ]]; then
log "Powerlevel10k theme is not installed. Installing..."
if ! $DRY_RUN; then
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$theme_dir" || {
log "Failed to clone Powerlevel10k repository. Please check your network connection." "error"
exit 1
}
else
log "[DRY-RUN] Would install Powerlevel10k theme"
fi
else
log "Powerlevel10k theme is already installed."
fi
}
# Appends additional shell configurations to .zshrc
append_shell_configs_to_zshrc() {
local zshrc="$HOME/.zshrc"
local backup_zshrc="$HOME/.zshrc.backup.$(date +%Y%m%d%H%M%S)"
if [[ -f "$zshrc" && ! -f "$backup_zshrc" ]]; then
log "Backing up existing .zshrc to $backup_zshrc"
if ! $DRY_RUN; then
cp "$zshrc" "$backup_zshrc"
else
log "[DRY-RUN] Would backup $zshrc to $backup_zshrc"
fi
fi
for config in "${SHELL_CONFIGS[@]}"; do
if ! grep -Fqx "$config" "$zshrc" 2> /dev/null; then
log "Appending configuration to .zshrc: $config"
if ! $DRY_RUN; then
echo "$config" >> "$zshrc"
else
log "[DRY-RUN] Would append configuration to .zshrc: $config"
fi
else
log "Configuration already present in .zshrc: $config"
fi
done
}
# Ensures that Zsh is set as the default shell
check_default_shell() {
local zsh_path
zsh_path=$(command -v zsh)
if [[ "$SHELL" != "$zsh_path" ]]; then
log "Changing default shell to Zsh..."
if ! $DRY_RUN; then
if ! grep -Fxq "$zsh_path" /etc/shells; then
echo "$zsh_path" | sudo tee -a /etc/shells > /dev/null || {
log "Failed to add $zsh_path to /etc/shells. Please ensure you have sudo privileges." "error"
exit 1
}
fi
chsh -s "$zsh_path" || {
log "Failed to change the default shell. Please ensure you have the necessary permissions." "error"
exit 1
}
else
log "[DRY-RUN] Would change default shell to Zsh"
fi
else
log "Zsh is already set as the default shell."
fi
}
# Main function that orchestrates the setup process
main() {
log "Running setup.zsh version $SCRIPT_VERSION" "info"
check_macos_compatibility
check_user_privileges
check_network_connectivity
check_dependencies
install_xcode
install_or_update_homebrew
install_brew_items
install_oh_my_zsh
install_powerlevel10k
append_shell_configs_to_zshrc
check_default_shell
log "Setup completed with warnings." "warning"
log "Please restart your terminal or source your .zshrc to apply changes."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy