CLI.NEWS / TUTORIAL

Using the CLI on macOS

From opening the terminal to installing development tools — a systematic introduction to the macOS command-line environment, shell configuration and everyday development workflows.

Opening the terminal

macOS ships with Terminal.app in the Applications → Utilities folder, and you can also launch it instantly with Spotlight (⌘ + Space). If you want more advanced terminal features, iTerm2 is the most common third-party choice.

When the terminal opens, you will usually see a prompt ending in % or $. That prompt means the system is ready to accept commands. The text before it often includes your username, host name, and current directory.

username@MacBook-Pro ~ %
↑ username · hostname · current directory (~ means home) · prompt character

macOS also lets you open a terminal directly from Finder using Services, which is handy when you want to start from a specific folder.

Default shell: Zsh

Since macOS Catalina (10.15), Zsh has been the default shell instead of Bash. Zsh keeps most Bash-compatible syntax while offering stronger completion, path expansion, and customization.

# Check current shell
$ echo $SHELL
/bin/zsh

# Check Zsh version
$ zsh --version
zsh 5.9 (x86_64-apple-darwin24.0)

Zsh configuration usually lives in ~/.zshrc, which loads whenever a new terminal session starts. Aliases, environment variables, prompt settings, and plugin configuration often live there.

Homebrew package manager

Homebrew is the most common package manager on macOS. It is used for both command-line tools and desktop apps, and it is often the backbone of a local development setup.

# Install Homebrew
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install a tool (for example Git)
$ brew install git

# Install a desktop app (for example VS Code)
$ brew install --cask visual-studio-code

# Update installed packages
$ brew update && brew upgrade
  • formula vs caskbrew install is mainly for command-line tools, while brew install --cask is for GUI apps.
  • Common dev tools — Tools like git, node, python, ripgrep, jq, wget, and tree can all be installed through Homebrew.

Developer tool setup

Most macOS development environments begin with Xcode Command Line Tools. That package includes the compiler, Git, Make, and other foundational utilities that many tools depend on.

# Install Xcode Command Line Tools
$ xcode-select --install

# Verify Git is installed
$ git --version

# Configure Git user info
$ git config --global user.name "Your Name"
$ git config --global user.email "your@email.com"
Recommended setup sequence:
  1. Install Xcode Command Line Tools.
  2. Install Homebrew.
  3. Use Homebrew to install runtimes and core tools like Node.js and Python.
  4. Configure Git and generate SSH keys.
  5. Add your editor (VS Code) and terminal (iTerm2) if needed.

Shell configuration

Zsh can be deeply customized through ~/.zshrc. Good shell configuration saves time every day and makes common workflows easier to repeat.

# Set aliases
alias ll="ls -la"
alias gs="git status"
alias gp="git push"

# Add environment variables
export PATH="$HOME/.local/bin:$PATH"

# Reload config after changes
$ source ~/.zshrc
  • Aliases — Create short names for high-frequency commands, such as alias k=kubectl.
  • Environment variablesPATH controls where the system looks for executables.
  • Plugin frameworks — Oh My Zsh remains one of the most popular ways to add themes and shell plugins.

Productivity tips

These habits can make terminal work on macOS noticeably faster and smoother.

  • Tab completion

    Type the first few characters of a command or path and press Tab. Zsh will complete it or show likely options.

  • History search

    Press Ctrl+R to search previously executed commands instead of scrolling through history line by line.

  • Pipes and redirection

    Use | to pass output into another command, and > to write output into a file.

  • Multiple sessions

    Split panes in iTerm2 are useful when you want one terminal running a service and another watching logs.

  • Command substitution

    Use $(command) to embed command output inside another command, such as echo "Today is $(date)".

Next steps

Once the basics are comfortable, these are good directions to deepen your macOS CLI workflow:

  1. Learn shell scripting and turn repeated tasks into .sh files.
  2. Get comfortable with SSH keys and ~/.ssh/config.
  3. Use tmux or screen for long-running sessions.
  4. Explore Docker Desktop for Mac for local container workflows.
  5. Try AI coding assistants such as Claude Code or Copilot CLI in the terminal.

References