Last active
September 4, 2024 07:18
-
-
Save madisonsites/758f544151f557941e718f3cbe61d79e to your computer and use it in GitHub Desktop.
Setup script for a new laptop.
This file contains hidden or 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 | |
echo "Starting setup..." | |
# Install Homebrew | |
echo "Installing Homebrew..." | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
# Add Homebrew to PATH (assuming default installation location) | |
/opt/homebrew/bin/brew shellenv >> ~/.zshrc | |
eval "$(/opt/homebrew/bin/brew shellenv)" | |
# Install applications via Homebrew Cask | |
echo "Installing applications via Homebrew..." | |
brew install --cask google-chrome | |
brew install --cask spark | |
brew install --cask rectangle | |
brew install --cask iterm2 | |
brew install --cask 1password | |
brew install --cask alfred | |
brew install --cask gitkraken | |
brew install --cask meeter | |
brew install --cask setapp | |
# Install GitHub CLI | |
echo "Installing GitHub CLI..." | |
brew install gh | |
# Install 1Password CLI | |
echo "Installing 1Password CLI..." | |
brew install 1password-cli | |
# Install Oh My Zsh | |
echo "Installing Oh My Zsh..." | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
# Install duti to manage file associations | |
echo "Installing duti..." | |
brew install duti | |
# Set iTerm to load preferences from iCloud | |
echo "Configuring iTerm to load preferences from iCloud..." | |
ICLOUD_ITERM_PREFS_DIR="$HOME/Library/Mobile Documents/com~apple~CloudDocs/iTerm" | |
defaults write com.googlecode.iterm2 PrefsCustomFolder -string "$ICLOUD_ITERM_PREFS_DIR" | |
defaults write com.googlecode.iterm2 LoadPrefsFromCustomFolder -bool true | |
# Setup aliases | |
git config --global --add --bool push.autoSetupRemote true | |
echo "Setting up aliases..." | |
cat <<EOT >> ~/.zshrc | |
# Custom Aliases | |
alias co="checkout" | |
alias g="git" | |
alias gap="git add --intent-to-add . && git add --patch" | |
alias gcb="git branch | grep '^\*' | cut -d' ' -f2 | tr -d '\n' | pbcopy" | |
alias gcd="git checkout master && git pull origin && git prune" | |
alias gco="git checkout" | |
alias gcm="git commit -m" | |
alias gfix="git commit -m 'f' -n" | |
alias gp="git push" | |
alias gpf="git push -f" | |
alias grb="git rebase -i master" | |
alias gst="git status" | |
alias publish="git push -f origin \$(git branch)" | |
alias stash="git stash --include-untracked" | |
EOT | |
# Update Git config with aliases | |
echo "Updating Git config with aliases..." | |
git config --global alias.co "checkout" | |
git config --global alias.st "status" | |
git config --global alias.ca "commit --amend --no-edit" | |
git config --global alias.cm "commit -m" | |
git config --global alias.br "branch" | |
git config --global alias.branch-name "rev-parse --abbrev-ref HEAD" | |
git config --global alias.unstage "reset HEAD --" | |
git config --global alias.aa "add --all --intent-to-add" | |
git config --global alias.ap "add -p" | |
git config --global alias.plog "log --pretty=oneline" | |
git config --global alias.gpo "pull origin" | |
git config --global alias.gpd "pull origin dev" | |
git config --global alias.gpf "push --force-with-lease" | |
git config --global alias.grb "rebase -i" | |
git config --global alias.grbd "rebase -i dev" | |
git config --global alias.gfix "commit -m 'f'" | |
git config --global alias.gcd '!git checkout $(git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@") && git pull origin && git remote prune origin' | |
# Set VSCode as default for Xcode file types | |
echo "Setting VSCode as the default application for Xcode file types..." | |
duti -s com.microsoft.VSCode .swift all | |
duti -s com.microsoft.VSCode .h all | |
duti -s com.microsoft.VSCode .m all | |
duti -s com.microsoft.VSCode .xcodeproj all | |
duti -s com.microsoft.VSCode .xcworkspace all | |
duti -s com.microsoft.VSCode .plist all | |
# Activate Alfred with license from 1Password | |
echo "Activating Alfred..." | |
# Replace 'alfred-license' with the actual 1Password item name or ID | |
ALFRED_LICENSE=$(op item get 'alfred-license' --field license-key) | |
if [ -n "$ALFRED_LICENSE" ]; then | |
echo "Alfred license retrieved. Activating Alfred..." | |
# Open Alfred and insert the license key (this might require additional automation) | |
open -a "Alfred 5" --args --activate "$ALFRED_LICENSE" | |
else | |
echo "Failed to retrieve Alfred license from 1Password." | |
fi | |
# Prompt for GitHub token setup | |
echo "Please generate a GitHub personal access token at the following URL:" | |
echo "https://github.com/settings/tokens" | |
echo "And follow the instructions to link 1Password to GitHub using this link:" | |
echo "https://developer.1password.com/docs/cli/shell-plugins/github/" | |
echo "Setup complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment