What I use to setup a Mac
Check installations to see if they have different Intel and Apple packages.
- Has code that it installs system wide that many things will need to use on a Mac
- From Apple Mac App Store
- Let fully install, might take several hours
- Open once and accept terms and conditions
- Open Preferences/Settings and go to the 'Locations' tab, then on that page for the 'Command Line Tools' option, pick a Xcode
- On Apple silicon, Mx chip, after opening Xcode, it should prompt to install Rosetta
- Better CLI
- Some features: Split panes, global search, copy/paste, configurability, 24 bit and 256 color mode, more
- Download: https://iterm2.com/
- After installation, in settings, set to have infinite scrollback
- Find a color theme if you'd like: iTerm2 themes
- Silence the 'Last Login' line when opening the terminal by adding a file to home
directory:
touch ~/.hushlogin
Mac: See Hidden Files
$ defaults write com.apple.finder AppleShowAllFiles -bool TRUE;killall Finder
- IDE
- Download https://code.visualstudio.com/
- Configuration:
- Set
terminal.integrated.scrollback
,terminal.integrated.persistentSessionScrollback
, andterminal.integrated.shellIntegration.history
values to 9999999999999 to have basically unlimited history
- Set
- Git GUI
- Download: https://desktop.github.com/
- Docker GUI
- Download: https://www.docker.com/products/docker-desktop/
- Package Manager
- Install instructions
- In July 2022, installation was:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- In July 2022, installation was:
- From the installation page, it says:
This script installs Homebrew to its preferred prefix - /usr/local for macOS Intel - /opt/homebrew for Apple silicon - /home/linuxbrew/.linuxbrew for Linux
- 🍎 Apple silicon:
- Follow install instructions
- TL;DR: they want this to be put in the .zshrc file:
export HOMEBREW_PREFIX="/opt/homebrew"; export HOMEBREW_CELLAR="/opt/homebrew/Cellar"; export HOMEBREW_REPOSITORY="/opt/homebrew"; export PATH="/opt/homebrew/bin:/opt/homebrew/sbin${PATH+:$PATH}"; export MANPATH="/opt/homebrew/share/man${MANPATH+:$MANPATH}:"; export INFOPATH="/opt/homebrew/share/info:${INFOPATH:-}";
- If a ~/.zshrc file does not exist yet, create one and put the above in it
- See this article: Upgrading Bash on macOS
- TL;DR of article:
- Mac has an old version of bash installed from 2007 (As of Aug. 2021)
- You want to:
- Install the latest version of Bash
- “Whitelist” new Bash as a login shell
- Set new Bash as the default shell
$ brew install bash $ sudo vim /etc/shells # Add to bottom of file: # Intel Mac /usr/local/bin/bash # Apple silicon Mac /opt/homebrew/bin/bash # The above will whitelist the Bash installed by Homebrew # Now set the Homebrew Bash as the default: # Intel Mac $ chsh -s /usr/local/bin/bash # Apple silicon Mac $ chsh -s /opt/homebrew/bin/bash # Change bash for root user # Intel Mac $ sudo chsh -s /usr/local/bin/bash # Apple silicon Mac $ sudo chsh -s /opt/homebrew/bin/bash
- Tell scripts to use whatever version of Bash they see first on the PATH. You can
do this by putting this line at the top of scripts. This tells it to inspect the
PATH on the local machine and use whatever Bash it finds first:
#!/usr/bin/env bash echo $BASH_VERSION
- Both System and User Bash will exist in tandem
- System default Bash:
/bin/bash
- User installed Bash, using the above method:
/usr/local/bin/bash
# Intel Mac/opt/homebrew/bin/bash
# Apple silicon Mac
- System default Bash:
- Install Zsh with Homebrew
- Check system is pointing to Brew installation of ZSH
- Intel
- This is going to be like the bash installation, in that, by using brew, it
will install zsh in /usr/local/bin/zsh and the system version will be in
/bin/zsh. If you echo PATH, the default path has /usr/local/bin listed
before /bin and the system will run the first one it finds when searching
locations listed in the PATH, so it will run the brew one first. All this
meaning, your system should be automatically pointing to the brew version.
You can double check though, if you want, by checking with
which -a zsh
and it should show two versions, then check the PATH and see which is listed fist on the path.
- This is going to be like the bash installation, in that, by using brew, it
will install zsh in /usr/local/bin/zsh and the system version will be in
/bin/zsh. If you echo PATH, the default path has /usr/local/bin listed
before /bin and the system will run the first one it finds when searching
locations listed in the PATH, so it will run the brew one first. All this
meaning, your system should be automatically pointing to the brew version.
You can double check though, if you want, by checking with
- 🍎 Apple silicon
- Same as above but
/opt/homebrew
is not on the default PATH. However, above when we installed Homebrew, this was taken care of when we created a~/.zshrc
file and put a line that added/opt/homebrew
to the PATH
- Same as above but
- System ZSH:
/bin/zsh
- User installed ZSH using this method:
/usr/local/bin/zsh
or/opt/homebrew/bin/zsh
- Intel
- Do the same thing we did above, for bash, now for Zsh:
$ brew install zsh $ sudo vim /etc/shells # Add to bottom of file: # Intel Mac /usr/local/bin/zsh # Apple silicon Mac /opt/homebrew/bin/zsh # The above will whitelist the Zsh installed by Homebrew # Now set the Homebrew Zsh as the default: # Intel Mac $ chsh -s /usr/local/bin/zsh # Apple silicon Mac $ chsh -s /opt/homebrew/bin/zsh # Change bash for root user # Intel Mac $ sudo chsh -s /usr/local/bin/zsh # Apple silicon Mac $ sudo chsh -s /opt/homebrew/bin/zsh
- Set IDE to use the Homebrew ZSH for its integrated terminal, if it has one
- VS Code: Code -> Preferences -> Settings, open settings, search for
terminal.integrated.defaultProfile
, set the value to be the Homebrew ZSH for your operating system
- VS Code: Code -> Preferences -> Settings, open settings, search for
- Many programmer friendly, open source, fonts exist
- Look at some examples: NerdFonts Example Page
- Great one with ligatures: FiraCode
- Find a preferred font
- With the preferred font, we can patch it to add programmer glyphs using
Nerd Fonts
- Nerd Fonts has a script that can patch fonts to add the Nerd Fonts glyphs to a font
- Many fonts are already patched ready for download, like Fira Code pathed with Nerd Font
- Check README on current installation instructions, but read the bottom of it
- Make sure to install the patched fonts. In the example FiraCode, the readme is copied from FiraCode, verbatim, and then, has new instructions at the bottom added to it that are specific to patched Nerd Fonts. This is a link to the FiraCode section to read and follow.
- TL;DR: For FiraCode, don't click the download link in the README, that's the direct link to FiraCode original (not patched with Nerd Fonts). You need to go into each of the folders at the top and download a font from there. Quick link example
- Configure apps to use font (instructions below for Macs):
- iTerm2: iTerm2 -> Preferences -> Profiles -> Text, set Font to the font and tick the checkbox for 'Use ligatures'
- VS Code: Code -> Preferences -> Settings, open settings
- Search
editor.fontLigatures
, settrue
- Change the base font for VS Code with
editor.fontFamily
which also applies to the integrated terminal, or just change the font family for the integrated terminal withterminal.integrated.fontFamily
- The value for the default font says something like
Menlo, Monaco, 'Courier New', monospace
. Add the font to the front of that list, example:'FiraCode Nerd Font', Menlo, Monaco, 'Courier New', monospace
- Evaluates fonts in order and applies the first one it finds installed
- The value for the default font says something like
- Search
- Zsh plugin manager, loads fast
- Allows installation of Oh My Zsh and Prezto plugins
- zshrc file referenced in next steps has some things in it that use zinit
- Install with Homebrew (preferred) or from Github
- Homebrew preferred because it's easy to update with Homebrew
-
Make a .zshrc file at
~/.zshrc
if one doesn't exist yet -
As of July 2022, the Homebrew installation of Zinit requires this to be added to a .zshrc file:
source $(brew --prefix)/opt/zinit/zinit.zsh
- This file sets up command completion for Zinit
-
- Homebrew preferred because it's easy to update with Homebrew
- Every once in a while update Zinit and it's plugins
brew update zinit
orzinit self-update
zinit update
for all pluginszinit update <plugin>
for a specific plugin
- See vimrc file
- Personal preference, if you have a .p10k.zsh file, put it in your home folder now before we do the .zshrc file in the next step as it will install and use p10k and try to configure it, or use the one you have if it is put in the home directory now.
- On Mac, zsh will load the /etc/zshrc file first and then the ~/.zshrc file. Anything in the ~/.zshrc file overrides the /etc/zshrc file.
- See the zshrc file in this repo
brew install gh
gh auth login
- Copilot:
gh extension install github/gh-copilot
gh copilot config
- Set usage analytics to no.
$ ls
command replacement. Has glyphs from Nerd Fonts.- Github Link
brew install lsd
- Command Line
- Useful tool for a variety of small developer situations
- Website
- Homebrew or download
- For Windows: https://devtoys.app/
- Nicer curl for API's and URL's
- Website
- Homebrew, have a Desktop UI incoming, but not available as of mid 2022
- DB client
- Website
- Python version management
- Github
- Homebrew
- Add to .zshrc:
# pyenv export PYENV_ROOT="$HOME/.pyenv" export PATH="/Users/demon_slayer/.pyenv/shims:${PATH}"
- After installing, check that you have the
recommended build environment
- 🍎 Apple silicon, as of Sept. 2022, xz was not installed, had to
brew install xz
to get it. All the other ones were pre-installed (zlib, readline, tcl-tk, etc.)
- 🍎 Apple silicon, as of Sept. 2022, xz was not installed, had to
- Install some python versions and set one globally
$ pyenv install -l
$ pyenv install 3.x.x
$ pyenv global 3.x.x
- Python package, dependency, environment management
- Website
- Installation
- Add Poetry install location to your PATH in .zshrc file:
export PATH="$HOME/.local/bin:${PATH}"
- Add Poetry install location to your PATH in .zshrc file:
- Poetry defaults to create virtual environments in a central location, to create inside
the project in a .venv folder, set
poetry config virtualenvs.in-project true
- Clear python pycache:
$ find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
- Conda, from Anaconda, is a package installer. Poetry is another package installer, but Poetry is only Python. Conda can do python and non-python packages which is what data science needs because there are some packages that are not python that are used in data science. Mamba is a replacement for Conda as it is faster.
- Install Micromamba, which a small self-contained mamba without conda bloat.
- brew install, or from their docs:
"${SHELL}" <(curl -L micro.mamba.pm/install.sh)
- https://aseifert.com/p/python-environments/ Good explaination of env tools
- brew install, or from their docs:
- Create a
~/.mambarc
file to use conda-forge instead ofdefaults
for licensing reasons (this can also go in an environment file in a repo):
channels:
- conda-forge
- Another option is to use Poetry.
- When using Poetry with Data Science libraries, some libraries or functions, like
ARIMA, will rely on XGBoost. XGBoost relies on OpenMP for parallel processing. On
macOS, the OpenMP runtime library (libomp.dylib) isn't installed by default. Install
it with:
brew install libomp
Use Jupyter in VS Code.
black, isort, pytest, pytest-cov, pre-commit
- Black is an active linter, flake8 is a passive one