Skip to content

Instantly share code, notes, and snippets.

@isorna
Last active April 15, 2024 07:16
Show Gist options
  • Save isorna/4359b8cae5a4c4497611555b52b885f4 to your computer and use it in GitHub Desktop.
Save isorna/4359b8cae5a4c4497611555b52b885f4 to your computer and use it in GitHub Desktop.
My default MacOS configuration routine for new devices

Show hidden folders and files on MacOS

defaults write com.apple.finder AppleShowAllFiles true; killall Finder

Fix 'xcrun: error: invalid active developer path, missing xcrun'

xcode-select --install

  1. Login to the macOS desktop system and install Homebrew on your system (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/USERNAME/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
  1. Remove existing Node Versions
brew uninstall --ignore-dependencies node
brew uninstall --force node
  1. Install NVM on macOS
brew update
brew install nvm
  1. Create a directory for NVM in home

mkdir ~/.nvm

  1. Edit the following configuration file in your home directory

vim ~/.zshrc

Add the following lines to .zshrc

export NVM_DIR="$HOME/.nvm"
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"  # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"  # This loads nvm bash_completion
  1. Reload zsh

exec zsh

  1. Install Node.js with NVM
nvm ls-remote 				## See what Node versions are available to install
nvm install node    	## Installing Latest version
nvm install 14      	## Installing Node.js 14.X version
nvm ls								## After installing you can verify what is installed with
nvm use 14						## To set the node 14.X as default version
  1. sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  2. More themes
  1. Install the recomended MesloLGS fonts
  2. git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
  3. Set ZSH_THEME="powerlevel10k/powerlevel10k" in ~/.zshrc.
  4. Configure p10k: p10k configure.

Set up Git on Windows

To set up Git Bash on Windows, follow these steps:

  1. Download the Git for Windows installer from the official website.
  2. Run the installer and select the desired components. Make sure the “Git Bash” option is selected.
  3. Follow the rest of the installer prompts to complete the installation.

Set up Zsh on Git Bash

  1. Download the latest Zsh package from the MSYS2 package repository. The file will be named something like “zsh-5.8–5-x86_64.pkg.tar.zst”.
  2. Install an extractor that can open TAR and ZST archives, such as 7-Zip and facebook/zstd (named something like “zstd-v1.5.2-win64.zip”). First, use zstd to extract the TAR file. Later, use 7-Zip to extract the files into the Git Bash directory.
  3. Extract the archive’s files using 7-Zip (which should include etc and usr folders) into your Git Bash installation directory. This directory is usually located at "C:\Program Files\Git". If asked, merge the contents of the folder (no files should be overwritten).
  4. Open Git Bash and test Zsh: zsh.

IMPORTANT: Configure tab completion and history in Zsh using the first-use wizard. If, for some reason, it doesn’t appear, or you skipped it, re-run it:

autoload -U zsh-newuser-install
zsh-newuser-install -f

Create/edit the ~/.bashrc file: code ~/.bashrc.

Add the following content to the file:

if [ -t 1 ]; then
  exec zsh
fi

Save the file and close Git Bash. Once Zsh is installed and set as the default shell, you can access it by opening Git Bash. Now, your Git Bash will open a Zsh terminal.

Set VS Code to use Git Bash as default command-line shell

On VS Code settings, search for "Terminal > External: Windows Exec" and point to: C:\Program Files\Git\git-bash.exe. Then look for "Terminal > Integrated > Automation Profile: Windows" and edit settings.json to add:

"terminal.external.windowsExec": "C:\\Program Files\\Git\\git-bash.exe",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.shellIntegration.decorationsEnabled": "both",
"terminal.integrated.stickyScroll.enabled": true,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment