Skip to content

Instantly share code, notes, and snippets.

@pydanny
Last active October 3, 2024 12:51
Show Gist options
  • Save pydanny/b11f61cde65b984fe442cb7cc8d71d84 to your computer and use it in GitHub Desktop.
Save pydanny/b11f61cde65b984fe442cb7cc8d71d84 to your computer and use it in GitHub Desktop.
New mac installation

Terminal first!

  1. Try to avoid downloading anything directly. Rather, use homebrew, uv, and gh cli to install everything.
  2. At the end of each install, add the items suggested for going into the .zshrc

Install homebrew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install uv

Might need to also add miniconda, let's first see how well UV works with pytorch and cuda

curl -LsSf https://astral.sh/uv/install.sh | sh

Then install some pythons

uv python install 3.10 3.11 3.12

Setup and activate a python environment

uv venv --python 3.10.0
source .venv/bin/activate

Setup gh cli

Going to try to use gh cli (Github CLI) for everything

brew install gh
gh auth login

You may need to add ssh keys, instructions here

Install utilities

brew install --cask visual-studio-code
brew install bat # Really nice cat replacement
brew install tokei # counts lines of code
brew install tmux # many panes for your shell
brew install starship # General shell improvements

Install nbdev

In a virtualenv:

uv pip install nbdev setuptools
nbdev_install

Add to .zshrc

alias prep='nbdev_export && nbdev_clean && nbdev_trust'

More .zshrc tricks

function to remove deleted merged branches

function git-delete-merged-branches(){
    git branch --merged | egrep -v "(^\*|master|main|dev)" | xargs git branch -d
}

Python directory cleanup. Not as necessary as it used to be, but needed about once every few months

function rmpyc () {
    find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
}

Force pip to only work in a virtualenv

export PIP_REQUIRE_VIRTUALENV=tru

Starship config

First, make sure you have a Nerd font installed and enabled in the terminal.

brew install font-hack-nerd-font

Add to end of .zshrc

eval "$(starship init zsh)"

Add a starship config file:

mkdir -p ~/.config && touch ~/.config/starship.toml

Then use the nerd-font-symbols preset to make the shell explode in usefulness

starship preset nerd-font-symbols -o ~/.config/starship.toml

Install Atuin

Awesome shell history tool

brew install atuin
echo 'eval "$(atuin init zsh)"' >> ~/.zshrc

Configure pip and venv to use uv

# pip just calls uv
function pip() {
    uv pip "$@"
}

# Overwrite the venv caller so it uses our version of things
venv_wrapper() {
    if [[ "$1" == "activate" ]]; then
        source "$2/bin/activate"
        
        # Override pip in the virtualenv
        pip() {
            command uv pip "$@"
        }
        
    else
        virtualenv "$@"
    fi
}
alias venv=venv_wrapper

Install Jupyter Notebook extensions

pip install jupyter_contrib_nbextensions
pip install -U "notebook<7"
jupyter contrib nbextension install --user

Clone all your repos

gh repo clone ORG_NAME/REPO_NAME

An example might be:

gh repo clone pydanny/daniel-blog-fasthtml
@ncoop57
Copy link

ncoop57 commented Oct 1, 2024

Wanted to also link to how you can use brew to install nerd fonts: https://github.com/ryanoasis/nerd-fonts?tab=readme-ov-file#option-2-homebrew-fonts

@pydanny
Copy link
Author

pydanny commented Oct 3, 2024

Thanks Nate! I editing the doc to show that install.

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