Skip to main content

CLI Overview

Zed’s command-line interface (CLI) enables you to open files and directories, integrate with development tools, and control Zed from shell scripts and other applications.

Installation

macOS

Run the cli: install command from the command palette to install the zed CLI to /usr/local/bin/zed.

Linux

The CLI is included with Zed packages. The binary name may vary by distribution:
  • Most distributions: zed
  • Some distributions: zeditor
The CLI is typically installed in one of these locations:
  • /usr/local/bin/zed
  • /usr/bin/zed
  • ~/.local/bin/zed

Windows

The CLI is included with Zed. Add Zed’s installation directory to your PATH environment variable, or use the full path to zed.exe.

Basic Usage

zed [OPTIONS] [PATHS]...
Open a single file:
zed myfile.txt
Open a directory as a workspace:
zed ~/projects/myproject
Open multiple files or directories:
zed file1.txt file2.txt ~/projects/myproject

Line and Column Positioning

Open a file at a specific line:
zed myfile.txt:42
Open a file at a specific line and column:
zed myfile.txt:42:10
This positioning syntax works with any path argument.

Reading from Standard Input

Read content from stdin by passing - as the path:
echo "Hello, World!" | zed -
cat myfile.txt | zed -
ps aux | zed -
This creates a temporary file with the stdin content and opens it in Zed.

URL Support

The CLI can open URLs with these schemes:
  • zed:// - Zed-specific URLs (e.g., settings, extensions)
  • http:// and https:// - Web URLs
  • file:// - Local file URLs
  • ssh:// - SSH remote paths
Examples:
zed zed://settings
zed https://github.com/zed-industries/zed

Version Information

Print Zed’s version and app path:
zed --version
The output includes:
  • Release channel (stable, preview, nightly, or dev)
  • Version number
  • Commit SHA (if available)
  • Path to the Zed binary

Using Zed as Your Default Editor

Set Zed as your default editor for Git and other tools:
export EDITOR="zed --wait"
export VISUAL="zed --wait"
Add these lines to your shell configuration file:
  • Bash: ~/.bashrc
  • Zsh: ~/.zshrc
  • Fish: ~/.config/fish/config.fish
The --wait flag is essential for tools like Git that expect the editor to block until editing is complete.

macOS: Release Channel Switching

On macOS, launch a specific release channel by prefixing the command:
zed --stable myfile.txt
zed --preview myfile.txt
zed --nightly myfile.txt
This allows you to have multiple Zed versions installed and choose which one to use.

Exit Codes

CodeMeaning
0Success
1Error (details printed to stderr)
When using --wait, the exit code reflects the success of the editing session.

See Also

  • Open Command - Detailed documentation on opening files and projects
  • Diff Command - Comparing files with the --diff flag
  • CLI Options - Complete reference for all CLI flags and options