└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # The Perfect Web Development Setup for OS X / macOS 2 | 3 | This is what I perceive as the perfect web development OS X setup for JavaScript engineers. 4 | 5 | ## Goals 6 | 7 | - Never use `sudo`. Once you run a command with `sudo`, future commands are probably gonna be fucked up as well. 8 | - Automatically start all services. Don't bother keeping track a bunch of terminals running processes. 9 | - Don't shoot yourself in the foot. 10 | 11 | ## Environment Profile 12 | 13 | The new default shell in macOS is `zsh`. 14 | Create and update your profile at `~/.zshrc`. 15 | You may also want to `brew install zsh-completions zsh-autosuggestions`. 16 | 17 | ## XCode Command Line Tools 18 | 19 | First, you need to install XCode's command line tools. 20 | This installs a lot of tools like `git` which aren't needed for plebeians. 21 | 22 | ```zsh 23 | xcode-select --install 24 | ``` 25 | 26 | If you're on Apple Silicon, you may want to install Rosetta 2: 27 | 28 | ```zsh 29 | softwareupdate --install-rosetta 30 | ``` 31 | 32 | ## Install Homebrew 33 | 34 | [Homebrew](https://brew.sh/) is a macOS package manager that makes setting up all your services very easy. 35 | 36 | - For Intel Macs, you can just install with the simple script on the homepage. 37 | - For Apple Silicon Macs, I would recommend following this guide: https://soffes.blog/homebrew-on-apple-silicon 38 | 39 | ## Install everything 40 | 41 | Install everything with Homebrew. 42 | Here are some packages you might be interested in right now: 43 | 44 | ```zsh 45 | # for editing files 46 | brew install vim 47 | # always keep your git up to date by installing it with brew 48 | brew install git 49 | # download stuff 50 | brew install curl 51 | ``` 52 | 53 | ### Updating 54 | 55 | To update your packages, 56 | simply run: 57 | 58 | ```zsh 59 | brew update 60 | brew upgrade 61 | brew cleanup 62 | ``` 63 | 64 | ## Install node.js with nvm 65 | 66 | One thing many users do is install node.js globally. 67 | This is easy to get started or fine for servers, 68 | but it makes developing a pain. 69 | If you have to ever run `npm` with `sudo`, 70 | you're doing it wrong! 71 | 72 | [nvm](https://github.com/nvm-sh/nvm) is what I think is the best node version manager. 73 | It can be installed with homebrew! 74 | Yes, you use a package manager to install a version manager to install another package manager. 75 | It's stupid, but they all have their strengths. 76 | 77 | ```zsh 78 | brew install nvm 79 | ``` 80 | 81 | Then, follow the installation instructions: 82 | 83 | ```zsh 84 | brew info nvm 85 | ``` 86 | 87 | Then, set a default version of node.js. To use LTS: 88 | 89 | ```zsh 90 | nvm alias default lts/* 91 | ``` 92 | 93 | ### Default node.js version via `.nvmrc` 94 | 95 | The `.nvmrc` route of selecting the version of node to use is helpful when you are working on multiple projects with different versions of node. Create a `~/.nvmrc` file with a version of node you'd like to use or, for LTS versions, `lts/*`: 96 | 97 | ```zsh 98 | echo "lts/*" > ~/.nvmrc 99 | ``` 100 | 101 | Then install that version of node: 102 | 103 | ```zsh 104 | nvm install 105 | ``` 106 | 107 | Note that you should run `nvm install` once in a while to get an updated version of node. 108 | 109 | Then in your `~/.zshrc`, add the following line to always use the version of node the current working directory expects: 110 | 111 | ```zsh 112 | nvm use 113 | # or `nvm install`, which is slower, but will always install the latest version of node 114 | ``` 115 | 116 | Now, `nvm` will find the nearest `.nvmrc` file and use that version of node whenever the terminal starts. 117 | 118 | ### Using npm 119 | 120 | With `nvm`, you should never be calling any `npm` functions with `sudo`. 121 | `nvm` adds binaries installed globally to your `$PATH`, so if you install `npm i -g create-react-app`, `create-react-app` will automatically be added to your `$PATH`. 122 | 123 | To upgrade `npm`, run `npm -i -g npm`. 124 | 125 | To have [node binaries install faster](https://www.npmjs.com/package/node-gyp), add the following to your `~/.nvmrc`: 126 | 127 | ```zsh 128 | export NPM_CONFIG_JOBS=max 129 | ``` 130 | 131 | If you hate the npm progress bar like, add this to your `zshrc`: 132 | 133 | ```zsh 134 | export NPM_CONFIG_PROGRESS=false 135 | ``` 136 | 137 | ## Speed up node.js 138 | 139 | node.js has by default 4 thread pools [via libuv](http://docs.libuv.org/en/v1.x/threadpool.html) regardless of how many CPUs you have. If you have more CPUs and depending on what you're running locally, you may find a performance benefit in increasing this number. 140 | 141 | ```zsh 142 | export UV_THREADPOOL_SIZE=8 143 | ``` 144 | 145 | ## vim 146 | 147 | Homebrew's default version of vim doesn't allowing copying and supports the mouse, which IMO defeats the purpose of vim. Here's a basic `~/.vimrc` to fix that: 148 | 149 | ```vimrc 150 | set mouse= 151 | syntax on 152 | ``` 153 | 154 | ## thefuck? 155 | 156 | [thefuck](https://github.com/nvbn/thefuck) is a nifty tool that allows you to fix your previous CLI typos by just typing `fuck`. 157 | It perhaps has the greatest UX of all products, ever. 158 | 159 | Installing it is easy: 160 | 161 | ```zsh 162 | brew install thefuck 163 | ``` 164 | 165 | Then follow the instructions: 166 | 167 | ```zsh 168 | brew info thefuck 169 | ``` 170 | 171 | ## Setting up databases 172 | 173 | Homebrew makes setting up databases super easy. 174 | First step - install it with Homebrew: 175 | 176 | ```zsh 177 | brew install redis 178 | ``` 179 | 180 | Then you'll see information on your terminal like the following: 181 | 182 | ``` 183 | To have launchd start redis now and restart at login: 184 | brew services start redis 185 | ``` 186 | 187 | To read this information again, just type `brew info redis`. 188 | Run the command and, Voila! 189 | `redis-server` will always be running! 190 | You won't have to open a bunch of terminals to keep it running! 191 | 192 | Rinse and repeat for all your databases. 193 | 194 | ## git & GitHub 195 | 196 | You may want to set up a few configs. 197 | 198 | Always fast-forward when pulling (never rebase as it may mess up your local branch): 199 | 200 | ```zsh 201 | git config --global pull.ff only 202 | ``` 203 | 204 | - [Setup SSH for GitHub](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent) 205 | - [GitHub Desktop](https://desktop.github.com/) 206 | - [GitHub CLI](https://cli.github.com) 207 | 208 | ## Tools & Applications 209 | 210 | - [iStat Menus](http://bjango.com/mac/istatmenus/) - help me figure out if something's taking too much CPU, RAM, or network 211 | - [VS Code](https://code.visualstudio.com/) 212 | - [Docker for Mac](https://docs.docker.com/docker-for-mac/install/) 213 | - [EditorConfig](https://editorconfig.org/) 214 | - [Set up private npm token](https://docs.npmjs.com/using-private-packages-in-a-ci-cd-workflow) 215 | - [Set up ssh without typing your password](https://superuser.com/questions/8077/how-do-i-set-up-ssh-so-i-dont-have-to-type-my-password) 216 | - [Bittorrent blocklist](https://gist.github.com/shmup/29566c5268569069c256) 217 | - [Hosts file blocklist](https://github.com/StevenBlack/hosts) 218 | - [Google DNS](https://developers.google.com/speed/public-dns) 219 | - [Cloudflare DNS](https://1.1.1.1/dns/) 220 | --------------------------------------------------------------------------------