xfenix / bootstrap-macbook-for-python

Do you have a new MacBook, and are you a web developer who prefers working with languages like Python and TypeScript? This guide will assist you in setting up a highly efficient environment

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fresh macbook bootstrap

Say for example you got new macbook and you are web developer with stack consist of python for backend and/or typescript for frontend. This instruction will help you to prepare your macbook for work in cutting edge environment.

Basic setup

  1. Setup o my zsh
    sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  2. Generate ssh key:
    ssh-keygen -o -a 100 -t ed25519 -C "ad@xfenix.ru"
    Copy you key in the clipboard:
    cat ~/.ssh/id_ed25519.pub | pbcopy
    
  3. Install FiraCode font: https://github.com/tonsky/FiraCode
  4. Install chrome: https://www.google.com/chrome/
  5. Reccomended extensions:
    1. https://chrome.google.com/webstore/detail/ublock-origin/cjpalhdlnbpafiamejdnhcphjbkeiagm?hl=en
    2. https://chrome.google.com/webstore/detail/tab-suspender/fiabciakcmgepblmdkmemdbbkilneeeh?hl=en
    3. Also for Russian users: https://chrome.google.com/webstore/detail/%D0%BE%D0%B1%D1%85%D0%BE%D0%B4-%D0%B1%D0%BB%D0%BE%D0%BA%D0%B8%D1%80%D0%BE%D0%B2%D0%BE%D0%BA-%D1%80%D1%83%D0%BD%D0%B5%D1%82%D0%B0/npgcnondjocldhldegnakemclmfkngch?hl=ru
    4. https://chrome.google.com/webstore/detail/grammar-spell-checker-%E2%80%94-l/oldceeleldhonbafppcapldpdifcinji
  6. Install homebrew:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  7. Install all necessary packages:
    brew install postman stats itsycal git iterm2 visual-studio-code pyenv gpg-suite shottr marta node dozer appcleaner keyboardcleantool karabiner-elements
    1. Dozer help you to organize your menu bar, since macbook notch gain troubles in this area
    2. Marta is the sublime-like completely free file manager
    3. AppCleaner help you clean garbage after application removal
    4. KeyboardCleanTool helps you to clean you keyboard! Very useful app for every developer
    5. Shottr literally best screenshot tool
    6. (Optional) Karabiner elements will be useful for remapping keys on the Russian keyboard layout. This really helps for ~ symbol return. On other keyboard layouts it not so useful by default
  8. Configure Iterm2:
    1. It helps not to disturb you
    2. Best font
    3. Good looking + Guake/Quake like behavior
  9. For macbook with Apple chip (M1, M1 pro, M1 max) install Rosetta2:
    softwareupdate --install-rosetta
    
  10. Install docker dekstop: https://www.docker.com/products/docker-desktop
  11. Setup git client:
    1. Generate GPG key in GPG keychain
    2. Run command:
      gpg --list-secret-keys
      Then copy following key: gpg key
    3. Setup:
      git config --global user.name "Denis Anikin"
      git config --global user.email ad@xfenix.ru
      git config --global user.signingkey KEY_FROM_PREVIOUS_STEP
      git config --global commit.gpgsign true
    4. Export GPG key in GPG keychain
    5. Paste it in https://github.com/settings/gpg/new
  12. File things:
    1. Create projects dir mkdir ~/web/
    2. Exclude from spotlight indexing (greatly reduce CPU pressure):  -> Settings -> Spotlight -> Privacy, press +, then ⌘ + shift + g and enter following paths:
      1. ~/web/
      2. ~/Library/Containers

Python part

  1. Setup pyenv
    echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
    echo 'eval "$(pyenv init -)"' >> ~/.zshrc
  2. Install and select desired python
    pyenv install 3.12.1
    pyenv global 3.12.1
  3. Install all necessary packages
    pip install ruff mypy
  4. Configure poetry:
    poetry config cache-dir ~/.cache/pypoetry/
    
  5. Dont forget to restart bash/zsh session!

VSCode configuration

This config meant for python development. But you can grab any part of it for other purposes.

  1. Open the Command Palette (⌘ + ⇧ + P on Mac) OR View ❯ Command Palette
  2. Type shell command to find Shell Command: Install 'code' command in PATH command
  3. Install extensions:
    code --install-extension wk-j.save-and-run
    code --install-extension esbenp.prettier-vscode
    code --install-extension GitHub.github-vscode-theme
    code --install-extension helgardrichard.helium-icon-theme
    code --install-extension mde.select-highlight-minimap
    code --install-extension miguelsolorio.fluent-icons
    code --install-extension ms-python.mypy-type-checker
    code --install-extension ms-python.python
    code --install-extension ms-python.vscode-pylance
    code --install-extension yzhang.markdown-all-in-one
  4. Place following in you settings.json:
    {
        "workbench.colorTheme": "GitHub Dark",
        "workbench.iconTheme": "helium-icon-theme",
        "workbench.productIconTheme": "fluent-icons",
    
        "markdown.preview.typographer": true,
        "markdown.extension.orderedList.marker": "one",
    
        "editor.wordBasedSuggestions": false,
        "editor.fontFamily": "FiraCode-Retina",
        "editor.fontSize": 14,
        "editor.fontLigatures": true,
        "editor.formatOnPaste": true,
        "editor.formatOnType": true,
        "editor.formatOnSave": true,
        "editor.renderWhitespace": "all",
        "editor.rulers": [120],
    
        "debug.console.fontSize": 14,
    
        "terminal.integrated.fontSize": 14,
    
        "emmet.triggerExpansionOnTab": true,
        "emmet.includeLanguages": {
            "plaintext": "html"
        },
    
        "saveAndRun": {
            "commands": [
                {
                    "match": ".py",
                    "cmd": "ruff check --config=${workspaceFolder}/pyproject.toml ${file}",
                    "silent": true,
                },
                {
                    "match": ".py",
                    "cmd": "ruff format --config=${workspaceFolder}/pyproject.toml ${file}",
                    "silent": true,
                },
            ]
        },
    }
  5. Dont forget to replace xfenix with you user!

About

Do you have a new MacBook, and are you a web developer who prefers working with languages like Python and TypeScript? This guide will assist you in setting up a highly efficient environment