Skip to content

Instantly share code, notes, and snippets.

@morristech
Forked from TomasBeuzen/laptop_setup_v2.md
Created February 22, 2022 18:30
Show Gist options
  • Select an option

  • Save morristech/a17ebecfa266c358b833ba75235a7797 to your computer and use it in GitHub Desktop.

Select an option

Save morristech/a17ebecfa266c358b833ba75235a7797 to your computer and use it in GitHub Desktop.
Steps taken when setting up my MacBook Air (M1)

New Mac Setup

This gist documents the setup of my Mac, primarily for personal use and data science.

Hardware/software details:

  • MacBook Air (M1, 2020)
  • Big Sur (11.2.2)

Installs

  • Install HomeBrew
  • Install the following with homebrew:
    • Alfred
    • 1password
    • VSCode
    • Mini-forge
    • Starship cross-shell prompt
    • Imagemagick
    • Inkscape
    • Spotify
    • Zoom
    • Slack
    • karabiner-elements (for mechanical keyboard)
    • R
    • RStudio
    • zsh-autosuggestions
    • zsh-syntax-highlighting
    • nano
    • postgresql
    • postgis

Alfred set up

Starship set up

  • Create config file: nano ~/.config/starship.toml
  • Add the following (other options can be found in the starship documentation):
[directory]
truncate_to_repo = true
truncation_length = 3
truncation_symbol = "…/"

[conda]
format = "[$symbol$environment](bold green) "

[python]
format = "[$symbol$version](bold yellow) "

[git_status]
conflicted = "🏳"
ahead = "πŸŽπŸ’¨"
behind = "😰"
diverged = "😡"
untracked = "πŸ€·β€"
stashed = "πŸ“¦"
modified = "πŸ“"
staged = '[++\($count\)](green)'
renamed = "πŸ‘…"
deleted = "πŸ—‘"

[username]
style_user = "white"
format = "[$user]($style) "
show_always = false

Nano syntax highlighting

  • nano ~/.nanorc
  • Add the following content which references the installed version config from homebrew:
    include "/opt/homebrew/Cellar/nano/*/share/nano/*.nanorc"
    

Configure shell

  • nano ~/.zshrc

    # aliases
    alias l="git status"
    alias jn="jupyter notebook"
    alias jl="jupyter lab"
    
    # autocomplete and syntax highlighting
    source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
    autoload -Uz compinit && compinit
    source /opt/homebrew/Cellar/zsh-syntax-highlighting/*/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
    
    # starship
    eval "$(starship init zsh)"
    

Git set up

  • git config --global core.editor nano
  • git config --global user.name "Tomas Beuzen"
  • git config --global user.email <email-address>
  • Make global gitignore: nano ~/.gitignore_global and add the following:
.DS_Store
.ipynb_checkpoints
.Trashes
.RHistory
__pycache__
~$*
~*
*~
.~
*.egg-info
.nbgrader.log
.coverage
.vscode
  • Apply with: git config --global core.excludesfile '~/.gitignore_global'

VS Code set up

  • Install the following extensions from the marketplace:
    • Python
    • Better TOML
    • GitHub Theme
    • Material Icon Theme
    • Markdown All In One
    • Bracket Pair Colorizer 2
    • Python Docstring Generator
    • reStructuredText
    • markdownlint
  • Add the following user settings:
{
    "workbench.colorTheme": "GitHub Dark",
    "workbench.iconTheme": "material-icon-theme",
    "workbench.settings.useSplitJSON": true,
    "autoDocstring.docstringFormat": "numpy",
    "editor.formatOnSave": true,
    "python.formatting.provider": "black",
    "python.linting.lintOnSave": true,
    "python.linting.flake8Enabled": true,
    "editor.fontLigatures": false,
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Args": [
        "--max-line-length=88",
        "--ignore=E203"
    ],
    "workbench.editorAssociations": [
        {
            "viewType": "jupyter.notebook.ipynb",
            "filenamePattern": "*.ipynb"
        }
    ],
    "explorer.confirmDelete": false,
    "explorer.confirmDragAndDrop": false,
    "launch": {
        "configurations": [],
        "compounds": []
    },
    "python.defaultInterpreterPath": "/opt/homebrew/Caskroom/miniforge/base/bin/python",
    "terminal.integrated.inheritEnv": false,
    "workbench.settings.editor": "json",
    "jupyter.alwaysTrustNotebooks": true,
    "editor.wordWrap": "on",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment