Skip to content

Instantly share code, notes, and snippets.

@rchatham
Last active March 25, 2024 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rchatham/8824b094ce32523b2cc8f82fe1eb9df7 to your computer and use it in GitHub Desktop.
Save rchatham/8824b094ce32523b2cc8f82fe1eb9df7 to your computer and use it in GitHub Desktop.
Setup script for new macOS
#!/bin/bash
# Make Dock only show active apps
defaults write com.apple.dock static-only -bool true; killall Dock
defaults write com.apple.finder _FXSortFoldersFirst -bool true; killall Finder
# Check if Homebrew is installed and install if not
if ! command -v brew &> /dev/null
then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Update .zshrc if not exists - done before installing zsh
if [ ! -f "$HOME/.zshrc" ]
then
echo "Setting up .zshrc..."
curl https://gist.githubusercontent.com/rchatham/d798827061fbd1e1c04a2c1b0c284a00/raw >> ~/.zshrc
fi
# Install Homebrew packages
brew install --cask clipy iterm2 amethyst anaconda vlc blackhole-16ch
brew tap homebrew/cask-fonts
brew install zsh zsh-autosuggestions zsh-syntax-highlighting powerlevel10k font-hack-nerd-font neovim bat eza gh tmux rg fd fzf dust btop jq comby zoxide tldr midnight-commander 1password-cli
$(brew --prefix)/opt/fzf/install
# Install Oh My Zsh if not already installed
if [ ! -d "$HOME/.oh-my-zsh" ]
then
echo "Installing Oh My Zsh..."
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
fi
# Clone powerlevel10k theme if it is not already installed
P10K_DIR="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
if [ ! -d "$P10K_DIR" ]; then
echo "Installing powerlevel10k theme..."
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$P10K_DIR"
else
echo "powerlevel10k theme already installed."
fi
# Update tmux.conf if not exists
if [ ! -f "$HOME/.config/tmux/tmux.conf" ]
then
echo "Setting up tmux.conf..."
mkdir -p "$HOME/.config/tmux"
curl https://gist.githubusercontent.com/rchatham/4a2cd1bf32eaf1f749993dbb7859dadf/raw >> ~/.config/tmux/tmux.conf
fi
# Install Tmux plugins
if [ ! -d "$HOME/.tmux/plugins/tpm" ]
then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
tmux source ~/.config/tmux/tmux.conf
# Neovim config
if [ ! -d "$HOME/.config/nvim" ]
then
git clone https://github.com/rchatham/nvim-config.git .config/nvim
fi
# Python
brew install pyenv pyenv-virtualenv
# Ruby
brew install ruby rbenv ruby-build
# Swift tools
brew install aria2 xcodesorg/made/xcodes swiftformat swiftlint xcbeautify
xcodes install --latest --experimental-unxip
gem install xcodeproj
# Completions for xcodes
mkdir -p ~/.oh-my-zsh/completions
xcodes --generate-completion-script > ~/.oh-my-zsh/completions/_xcodes
# Git configuration
git config --global push.autoSetupRemote true
# GitHub CLI auth
if ! gh auth status &> /dev/null
then
echo "Logging into GitHub CLI..."
gh auth login
fi
# Update .zshrc if not exists - done before installing zsh
if [ ! -f "$HOME/.amethyst.yml" ]
then
echo "Setting up .amethyst.yml..."
curl https://gist.githubusercontent.com/rchatham/33278ad3893e903123954f17de44a0bf/raw >> ~/.amethyst.yml
fi
if [ ! -f "/Library/LaunchAgents/com.warpd.warpd.plist" ]
then
echo "Downloading warpd..."
curl -L https://github.com/rvaiya/warpd/releases/download/v1.3.5/warpd-1.3.5-osx.tar.gz | sudo tar xzvfC - / && launchctl load /Library/LaunchAgents/com.warpd.warpd.plist
fi
read -p "Do you want to install this csview and visidata? (y/n) " answer
if [ "$answer" != "${answer#[Yy]}" ]; then
echo "Installing csv tools..."
brew install csview saulpw/vd/visidata
npm install -g google-sheet-cli
fi
read -p "Do you want to install this Tetris? (y/n) " answer
if [ "$answer" != "${answer#[Yy]}" ]; then
echo "Installing Tetris..."
brew install samtay/tui/tetris
fi
echo "Remember to enable the 'Hack Nerd Font Mono' in iTerm2 > Settings > Profiles > Text > Font"
@rchatham
Copy link
Author

Run curl -s https://gist.githubusercontent.com/rchatham/8824b094ce32523b2cc8f82fe1eb9df7/raw | bash to remotely run this script from your machine.

@rchatham
Copy link
Author

It is useful to set iTerm2 > Settings > Profiles > {Default/Profile} > Keys > Presets > Terminal.app Compatibility for navigating text in the command line using standard mac keymaps.

@rchatham
Copy link
Author

rchatham commented Feb 22, 2024

If set -o vi is set in your .bashrc or .zshrc, you can use Esc to use j & k to navigate your command history and /{command}
with n & N to search your command history.

@rchatham
Copy link
Author

rchatham commented Feb 22, 2024

If bindkey "^X^E" edit-command-line is set on .zshrc, Ctrl-x+Ctrl-e will open the current command in your editor. (This is standard in Bash) https://stackoverflow.com/a/22656375/4525974

@rchatham
Copy link
Author

Using warpd keyboard mouse:

Grid Mode:

  • Press A-M-g (meta is the command key) to activate the warping process.
  • Use u,i,j,k to repeatedly navigate to different quadrants.
  • Press m to left click, , to middle click or . to right click.

Normal Mode:

  • Press A-M-c to activate normal mode.
  • Use the normal movement keys (default hjkl) to adjust the cursor.
  • Press m to left click, , to middle click or . to right click.
  • Press escape to quit.

A drag movement can be simulated from any of the above modes by focusing on the source and then pressing the drag_key (default v) which will cause normal mode to be activated for selection of the drag target.

@rchatham
Copy link
Author

rchatham commented Mar 7, 2024

Other tools and resources:

File Managers:

@rchatham
Copy link
Author

Set up a global .gitignore to prevent IDE files and other files related to local development from needing to be added to a individual repository's .gitignore. https://gist.github.com/subfuzion/db7f57fff2fb6998a16c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment