|
#!/bin/bash |
|
|
|
############ Prerequisites |
|
echo "Please enter your email for sshkey comment / git config: " |
|
read email |
|
|
|
echo "Please choose an iTerm theme at https://github.com/mbadolato/iTerm2-Color-Schemes/?tab=readme-ov-file#screenshots" |
|
read iterm_theme |
|
|
|
## Install homebrew and Xcode CLI |
|
command -v brew >/dev/null 2>&1 || { echo "Installing Homebrew.." |
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" |
|
} >&2; |
|
echo "Homebrew successfully installed, adding key bindings" |
|
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile |
|
eval "$(/opt/homebrew/bin/brew shellenv)" |
|
|
|
############ Git |
|
|
|
## install git |
|
echo "Installing git.." |
|
brew install git |
|
echo "git successfully installed. Setting global git user name and email." |
|
git config --global user.email "${email}" |
|
git config --global user.name "Full Name" |
|
|
|
## create global gitignore (see https://github.com/github/gitignore for inspiration) |
|
echo "Creating a global gitignore.." |
|
git config --global core.excludesfile ~/.gitignore |
|
touch ~/.gitignore |
|
echo '.DS_Store' >> ~/.gitignore |
|
echo '.envrc' >> ~/.gitignore |
|
echo '__pycache__/' >> ~/.gitignore |
|
echo '.cache/' >> ~/.gitignore |
|
echo '.env' >> ~/.gitignore |
|
echo 'env/' >> ~/.gitignore |
|
echo 'venv/' >> ~/.gitignore |
|
echo '.venv/' >> ~/.gitignore |
|
|
|
|
|
echo "Global gitignore created" |
|
|
|
## Generate SSH key |
|
ssh-keygen -t ed25519 -C "${email}" |
|
|
|
echo " |
|
Host github.com |
|
AddKeysToAgent yes |
|
UseKeychain yes |
|
IdentityFile ~/.ssh/id_ed25519 |
|
" >> ~/.ssh/config |
|
|
|
ssh-add --apple-use-keychain ~/.ssh/id_ed25519 |
|
|
|
############ Terminal |
|
|
|
## Get oh my zsh (plugins, themes for zsh). |
|
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" "" --unattended |
|
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions |
|
|
|
## Set zsh theme |
|
touch ~/.zshrc |
|
sed -i '' 's/ZSH_THEME=".*"/ZSH_THEME="jonathan"/g' ~/.zshrc |
|
sed -i '' 's/plugins=(git)/plugins=(git gitignore zsh-autosuggestions jump brew docker docker-compose python pip ssh-agent vscode)/g' ~/.zshrc |
|
|
|
## Fix zsh permissions for oh-my-zsh |
|
chmod 755 /usr/local/share/zsh |
|
chmod 755 /usr/local/share/zsh/site-functions |
|
|
|
source ~/.zshrc |
|
|
|
#### Brew casks and formulae (uv, atuin, fzf, etc.) |
|
xargs brew install < brew.txt |
|
xargs brew install --cask < brew_cask.txt |
|
|
|
############ Python, dbt & Utilities |
|
|
|
## install Python3 |
|
echo "Installing Python3..." |
|
brew install python3 |
|
echo "Python $(python3 --version) succesfully installed" |
|
|
|
# set pip and python to pip3 and python3 aliases (or remove if you prefer) |
|
echo "alias pip=pip3" >> ~/.zshrc |
|
echo "alias python=python3" >> ~/.zshrc |
|
|
|
## Environment variables with direnv |
|
brew install direnv |
|
echo 'eval "$(direnv hook zsh)"' >> ~/.zshrc |
|
echo '.envrc' >> ~/.gitignore # Add to global .gitignore |
|
|
|
|
|
############ Other programs |
|
## install visual studio code |
|
echo "Installing VS Code.." |
|
brew install --cask visual-studio-code |
|
|
|
# Add VS Code to PATH (to use 'code' command) |
|
echo 'export PATH="\$PATH:/Applications/Visual Studio Code.app/Contents/Resources/app/bin"' >> ~/.zprofile |
|
|
|
# be able to use vs code for e.g. git commit messages and wait |
|
echo 'export EDITOR="code --wait"' >> ~/.zshrc |
|
|
|
# Finish up .zshrc |
|
echo 'autoload -U +X compinit && compinit' >> ~/.zshrc |
|
echo 'autoload -U +X bashcompinit && bashcompinit' >> ~/.zshrc |
|
|
|
|
|
brew install zsh-syntax-highlighting |
|
echo "source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> ${ZDOTDIR:-$HOME}/.zshrc |
|
|
|
# iTerm Theme |
|
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git ~/.iterm2-color-schemes && cd ~/.iterm2-color-schemes |
|
tools/import-scheme.sh "${iterm_theme}" |
|
|
|
source ~/.zprofile |
|
source ~/.zshrc |
|
|
|
# Run certain apps to set permissions: |
|
/Applications/Rectangle.app/Contents/MacOS/Rectangle |
|
|