SG_ terminal · macOS
Tap any command to copy it.
Step back through commands you've already run. Nine times out of ten this beats retyping.
Move the cursor along the line. Hold ⌥ to jump a whole word at a time.
Autocomplete the file or folder you've started typing. Press it twice to list every match — the fix for long names and typos.
Jump to the start / end of the line. ⌃U and ⌃K delete everything before / after the cursor.
Search your history. Start typing a fragment, ⏎ to run it, ⌃C to back out.
Stop whatever's running — the way out of a stuck dev server. ⌃L clears the screen.
Repeats your last command. Mostly used as sudo !! — when something fails on permissions, this re-runs it with them.
The last thing you typed on the previous line. mkdir new-app then cd !$ puts you inside it.
Prints where you currently are. Your first move when a command isn't doing what you expect.
List everything here, dotfiles included — that's the -a. Plain ls hides .env and .git from you. Add -h for readable file sizes.
~ is your home folder, so this works from anywhere on the machine.
./ means "starting from right here". cd .. goes up one level, cd ../.. up two, and cd - snaps back to wherever you just were.
Type cd, a space, then drop a Finder folder onto the window — it pastes the full path, quotes and all. The quickest way into a deeply buried folder with spaces in its name.
Opens the current folder in Finder. Swap the full stop for a filename — open index.html — to open that file in whatever app owns it.
Same idea for VS Code: the full stop opens the whole folder as a project. code .env opens a single file. If code isn't found, run Shell Command: Install 'code' command in PATH from the VS Code command palette.
Creates the folder. -p creates every missing parent on the way down, so you get all three levels in one go.
Creates an empty file. If it already exists, nothing is lost — it just bumps the timestamp.
Copy. The original stays put — the standard first move after cloning a repo. Add -r to copy a folder and everything in it.
Move. Give it a new name in the same folder and it's a rename; give it a folder and it relocates the file. Either way the original is gone.
Adds that line to the end of the file, creating it if it doesn't exist.
Prints a file to the screen. For anything long use less package.json and press q to quit.
Deletes a folder and everything inside it. There's no Trash and no confirmation — read the path twice before you press ⏎.
Installs Homebrew, the package manager macOS doesn't ship with. From here on you install software by naming it instead of hunting down a .dmg, dragging it to Applications and never updating it again. Run this once per machine.
Command-line tools — node, git, ffmpeg, gh. Installed into your PATH, so they work in any terminal immediately.
A cask is a proper Mac app rather than a command. This downloads it, unpacks it and drops it in /Applications for you. Also works for rectangle, docker, google-chrome.
Refreshes the catalogue, then updates everything you've installed. brew list shows what you've got, brew uninstall [name] removes it cleanly.
The other pattern you'll meet constantly. curl fetches the installer script from the URL and the | pipes it straight into bash, which runs it — nothing is left on disk. The flags are worth knowing: -f fail on an HTTP error instead of saving the error page, -s silent, -S but still show real errors, -L follow redirects.
Downloads the repo into a new folder named after it. Run this from wherever you keep your projects.
The full stop is the destination, and it means "here, in the folder I'm already standing in" — no extra wrapper folder. Use it when you've already made and named the folder yourself, or when a host has given you an empty directory to fill.
What's changed, what's staged, what branch you're on. Run it constantly.
Here the full stop means "every change below this folder". && chains the three so each only runs if the one before it succeeded.
Creates a branch and moves you onto it. Drop the -c to switch to one that already exists.
An alias is a nickname for a command. Type this and gs works immediately — but only in this window, and only until you close it. To keep it, put the same line in your config file.
Your shell's config, read every time you open a terminal. macOS uses zsh — check with echo $SHELL. If the file doesn't exist yet, touch ~/.zshrc first.
A starter set to paste at the bottom of .zshrc. No spaces around the = — that's the one rule people trip over. Run alias on its own to list everything you've defined.
Reloads the config in the window you're already in. Without it your new alias won't exist until you open a fresh terminal.
Aliases can't take arguments — the moment you need one, write a function instead. "$1" is whatever you typed after the name, so mkcd new-app creates the folder and drops you into it. Goes in .zshrc the same way.
"Port 3000 is already in use." This finds whatever is holding the port and shuts it down. Change the number to match.
Puts the whole file on your clipboard, ready to paste into Vercel or wherever. pbpaste goes the other way.
Which one you're actually running, and what version. Settles most "but it works on my machine" arguments.
Digs that long command you ran last week out of your history. | feeds the output of one command into the next.