Skip to content

Instantly share code, notes, and snippets.

@mick-io
Last active February 6, 2024 20:41
Show Gist options
  • Save mick-io/b34db3de2f23ff917a5929d4da07983e to your computer and use it in GitHub Desktop.
Save mick-io/b34db3de2f23ff917a5929d4da07983e to your computer and use it in GitHub Desktop.
Bootstrap script for new computers.
#!/bin/zsh
homebrew_fomulas=(
bat
btop
curl
docker
fzf
gawk
gsed
git
go
httpie
jq
neofetch
neovim
node
python
ranger
ripgrep
spotify_player
tmux
tree
tree-sitter
tldr
yt-dlp
zsh
)
homebrew_casks=(
1password
1password-cli
alacritty
amethyst
caffeine
firefox
keybase
languagetool
nordvpn
zoom
)
npm_pkgs=(
eslint
nodemon
prettier
typescript
ts-node
)
pip_pkgs=(
black
flake8
isort
mypy
ptpython
pipenv
virtualenv
)
go_pkgs=(
github.com/go-delve/delve/cmd/dlv
github.com/incu6us/goimports-reviser
github.com/segmentio/golines
mvdan.cc/gofumpt
)
install_xcode() {
if xcode-select -p &>/dev/null; then
return 0
fi
echo "Installing Xcode Command Line Tools..."
xcode-select --install
if [ $? -ne 0 ]; then
echo "Xcode Command Line Tools installation failed."
return 1
fi
echo "Xcode Command Line Tools installed."
}
install_homebrew() {
if command -v brew &>/dev/null; then
return 0
fi
echo "Installing Homebrew..."
curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
if [ $? -ne 0 ]; then
echo "Homebrew installation failed."
return 1
fi
echo "Homebrew installed."
}
install_homebrew_fomulas() {
echo "Installing Homebrew Fomulas..."
if ! command -v brew &>/dev/null; then
echo "Homebrew not found, installing Homebrew..."
install homebrew
if [ $? -ne 0 ]; then
echo "Error installing Homebrew."
return 1
fi
fi
brew install $homebrew_fomulas[@]
if [ $? -ne 0 ]; then
echo "Error installing Homebrew Packages."
return 1
fi
}
install_homebrew_casks() {
echo "Installing Homebrew Cask..."
if ! command -v brew &>/dev/null; then
echo "Homebrew not found, installing Homebrew..."
install homebrew
if [ $? -ne 0 ]; then
echo "Error install Homebrew."
return 1
fi
fi
brew install --cask $homebrew_casks[@]
if [ $? -ne 0 ]; then
echo "Error installing homebrew packages."
return 1
fi
}
install_global_npm_packages() {
if ! command -v node &>/dev/null; then
brew install node
if [ $? -ne 0 ]; then
echo "Error installing node"
return 1
fi
fi
if ! command -v npm &>/dev/null; then
echo "NPM not found. Cannot install pacakges"
return 1
fi
npm install --global $npm_pkgs[@]
if [ $? -ne 0 ]; then
echo "Eror installing global NPM pacakges"
return 1
fi
}
install_pip_packages() {
echo "Installing PIP Packages..."
if ! command python3 -v &>/dev/null; then
echo "Python3 not found, installing Python3..."
brew install python
if [ $? -ne 0 ]; then
echo "Error installing Python3."
return 1
fi
fi
if ! command -n pip3 -v &>/dev/null; then
echo "PIP not found. cannot install packages."
return 1
fi
pip3 install --user -U $pip_pkgs[@]
if [ $? -ne 0 ]; then
echo "Eror installing PIP pacakges."
return 1
fi
}
install_go_packages() {
echo "Installing Go packages..."
if ! command go -v &>/dev/null; then
echo "Go not found, installing Go..."
brew install go
if [ $? -ne 0 ]; then
echo "Error installing Go."
return 1
fi
fi
for pkg in "${packages[@]}"; do
go install "$pkg@latest"
if [ $? -ne 0 ]; then
echo "Eror installing Go Package: '"$pkg"'."
return 1
fi
done
}
install_oh_my_zsh() {
echo "Installing Oh-My-Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
if [ $? -ne 0 ]; then
echo "Eror installing Oh-My-Zsh."
return 1
fi
}
install_nvchad() {
echo "Installing NvChad..."
if ! command git -v &>/dev/null; then
echo "Git not found, installing Git."
brew install git
if [ $? -ne 0 ]; then
echo "Error installing Git. Cannot install NvChad."
return 1
fi
fi
git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1 && nvim
if [ $? -ne 0 ]; then
echo "Error installing NvChad."
return 1
fi
}
# Clone dotfiles
# Install fonts
if [[ "$(uname)" == "Darwin" ]]; then
install_xcode
install_homebrew
install_global_npm_packages
install_pip_packages
install_go_packages
install_oh_my_zsh
install_nvchad
else
echo "You are not on MacOS"
fi
# configure_macos() {
# Bluetooh
## Connect Mouse & Keyboard
# Appearence
## Appearance = "Dark"
## Allow wallpaper tinting in windows = false
# Control Center
## Bluetooh in Menubar = true
## AirDrop in Menubar = true
## Sound in Menubar = "Always"
# Siri & Spotlight
## Ask Siri = false
# Privacy & Security
## Add Accessibility to nesscary apps
# Desktop & dock
## Automatically hide and show dock = true
## Click wallpaper to reveal desktop = "Only in stage manager"
## Set Default Web Browser = "Firefox"
## Automatically rearrange spaces on most recent use = false
# Displays
## Arrange Dispalys
# Touch ID & Password
## Add fingerprints
# Keyboard
## Set key repeat rate = "Fast"
## Delay until repeat = "Short"
# Keyboard shortcuts >
## Turn dock hiding on/off = false
## Use F1, F2 etc. keys as standard function keys = true
## Modifier Keys, Rebind capslock to escape
# Mouse
## Tracking speed = "Fast"
## Set secondary Button = "Click Right Side"
## More Gestures > Mission Control = false
# echo "Configuring MacOS..."
#
# target=1
# echo "Setting key repeat rate to $target."
# defaults write NSGlobalDomain KeyRepeat -int $target
# if [ $? -ne 0 ]; then
# echo "Failed to set key repeat rate."
# return 1
# fi
#
# target=10
# echo "Setting initial key repeat delay to $target."
# defaults write NSGlobalDomain InitialKeyRepeat -int $target
# if [ $? -ne 0 ]; then
# echo "Failed to set initial key repeat delay."
# return 1
# fi
#
# echo "Showing hidden files in Finder."
# defaults write com.apple.finder AppleShowAllFiles YES
# if [ $? -ne 0 ]; then
# echo "Failed to show hidden files in Finder."
# return 1
# fi
#
# echo "Reloading Finder..."
# killall Finder
# if [ $? -ne 0 ]; then
# echo "Failed to reload Finder."
# return 1
# fi
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment