Skip to content
Independent notebook · software, testing, and open source No ads · no sponsored posts · no affiliate links
Soham Parekh software notebook

Coding note / Desktop

macOS

Terminal habits and setup steps I look up less often now.

Shelf Desktop

Format Reference

All notes

These are the macOS notes I keep coming back to: a few terminal motions, a handful of editor shortcuts, and the steps for turning a fresh machine into a working one. They are written for someone who is comfortable opening Terminal but does not want to memorise the whole system.

Move around the terminal

  • Ctrl and E puts the cursor at the line's end.
  • Ctrl and A puts the cursor at the line's start.
  • Ctrl and W deletes the word before the cursor.
  • Ctrl and U deletes to the start of the line.
  • Option and the left or right arrow moves by word.

These motions work in most shells that use readline style editing. They save a surprising amount of reaching for the mouse.

Copy command output

On macOS, pbcopy sends text to the clipboard. On Linux, the equivalent is usually xclip. Piping a command into it is often faster than selecting text in the terminal window.

terminal
ls | pbcopy
pwd | pbcopy

Editor shortcuts worth learning

In Xcode, Ctrl and Command and E selects every occurrence in scope. Selecting a variable and then pressing Command and E sets it for a find, and Command and G moves to the next occurrence. Shift, Command, and G moves to the previous one.

To clear the workspace, Ctrl and Command and F enters full screen. Option and Command and T hides the toolbar. Command and 0 hides the navigator, Option and Command and 0 hides the inspector, and Shift and Command and Y hides the debug area. Option and Command and the left arrow folds the current block.

A clean setup, in order

  1. Restart and hold Command and R to enter recovery mode.
  2. Open Disk Utility and erase the startup disk if you want a clean system.
  3. Reinstall macOS and follow the prompts.
  4. Install Xcode from the App Store.
  5. Install Homebrew and use it for the rest of the command line tools.
  6. Install zsh and a shell framework if you want one.
  7. Install Git, Python, Node.js, and the editor you use most.
terminal
brew install zsh
brew install tree
brew install git
pip install virtualenv

Open Terminal preferences and choose a profile you like. A readable font and a sensible cursor colour make long sessions less tiring.

Copy a path from Finder

Right click a file or folder, then hold Option. The usual copy item changes to a command that copies the full path. Select it and paste the path wherever you need it.

Keep the machine awake and locked

In Energy Saver, choose the setting that keeps the machine awake even after the screen goes dark. In Security and Privacy, require a password as soon as the screen locks. Now you can darken the screen with a shortcut while the computer stays awake.

Verify a checksum

Use shasum to compute a digest, then compare it with the value published by the source. If the two strings differ, do not run the file. A checksum is a simple integrity check, not a guarantee of safety, but it catches a surprising number of bad downloads.

Field note

A clean machine is a chance to write down what you actually need. Most of the rest can wait.

Reference shelf

Official documentation and further reading for this note.