CLI Options Reference
Complete reference for all command-line options supported by the Zed CLI.Synopsis
Options
-w, --wait
Wait for all opened paths to be closed before exiting.
Behavior:
- For files: waits until all specified files are closed in Zed
- For directories: waits until the created window is closed
- Exit code reflects the success of the editing session
-a, --add
Add files to the currently open workspace.
Behavior:
- Opens paths in the currently focused window
- Does not create a new window
- If no window is focused, behavior is undefined
--new(mutually exclusive)--reuse(mutually exclusive)
-n, --new
Create a new workspace window.
Behavior:
- Always opens paths in a new window
- Works even if the paths are already open in another window
- Useful for working on the same project in multiple windows
--add(mutually exclusive)--reuse(mutually exclusive)
-r, --reuse
Reuse an existing window, replacing its workspace.
Behavior:
- Closes the current workspace in the active window
- Opens the new paths in the same window
- Preserves window position and size
--add(mutually exclusive)--new(mutually exclusive)
--diff <OLD_PATH> <NEW_PATH>
Open a diff view comparing two files or directories.
Syntax:
- OLD_PATH: The original or “before” file/directory
- NEW_PATH: The modified or “after” file/directory
--foreground
Run Zed in the foreground, keeping the terminal attached.
Behavior:
- Zed runs as a foreground process
- Terminal remains attached and shows log output
- Pressing Ctrl+C terminates Zed
- Debugging startup issues
- Viewing real-time logs
- Running Zed in controlled environments (e.g., containers)
--user-data-dir <DIR>
Set a custom directory for all user data.
Overrides default locations:
- macOS:
~/Library/Application Support/Zed - Linux:
$XDG_DATA_HOME/zed(typically~/.local/share/zed) - Windows:
%LOCALAPPDATA%\Zed
- Database
- Extensions
- Logs
- Settings
- Themes
- Testing with isolated settings
- Running multiple independent Zed configurations
- Using Zed in a portable setup
-v, --version
Print Zed’s version information and exit.
Output includes:
- Release channel (stable, preview, nightly, or dev)
- Version number
- Commit SHA (if available)
- Full path to the Zed binary
--zed <PATH>
Specify a custom path to the Zed application or binary.
Usage:
- macOS: Path to
.appbundle or binary insideContents/MacOS/ - Linux: Path to
zedorzed-editorbinary - Windows: Path to
zed.exeorZed.exe
- Using a development build
- Running a specific Zed version
- Testing changes before installation
--uninstall
Uninstall Zed from the system (macOS and Linux only).
Behavior:
- Removes the Zed application
- Deletes user data (database, extensions, logs)
- Removes configuration files
- Uninstalls the CLI
- macOS: ✓ Available
- Linux: ✓ Available
- Windows: ✗ Not available
--system-specs
Attempting to use this flag with the CLI produces an error.
Error message:
--system-specs instead of using the CLI
wrapper.
macOS:
--wsl <USER@DISTRO> (Windows only)
Specify the WSL username and distribution for opening paths.
Format:
- With username:
USER@DISTRO - Without username:
DISTRO(uses default user)
--dev-server-token <TOKEN>
This flag is no longer supported.
Error message:
Positional Arguments
[PATHS]...
Paths to files, directories, or URLs to open.
Supported formats:
- File paths:
myfile.txt,/home/user/file.txt - Directory paths:
.,~/projects/myproject - Paths with positioning:
file.txt:42,file.txt:42:10 - URLs:
zed://settings,https://example.com - Standard input:
-(must be the only path)
- Relative paths are resolved against the current working directory
- Paths are canonicalized to absolute paths
- Non-existent paths are handled gracefully
- Symlinks are resolved (on Unix systems)
macOS-Specific Options
Release Channel Selectors
On macOS, you can launch a specific release channel by using the channel name as a flag:--), the CLI
spawns the corresponding Zed version with the remaining arguments.
Requirements:
- The specified channel must be installed
- The channel name must be the first argument
- Available channels:
stable,preview,nightly
Platform-Specific Behavior
macOS
- CLI uses
LSOpenFromURLSpecto launch the app bundle - Supports
.appbundles and raw binaries - Version information read from
Info.plist
Linux
- CLI forks a background process to launch Zed
- Uses Unix domain sockets for IPC
- Flatpak: CLI can escape the sandbox to run on the host
Windows
- CLI uses named pipes for IPC
- Checks for single instance using a mutex
- WSL integration with automatic path conversion
Exit Codes
| Code | Meaning |
|---|---|
0 | Success |
1 | Error (details printed to stderr) |
1 | Bundle detection failed |
1 | IPC handshake failed |
1 | Unsupported flag used (e.g., --system-specs) |
1 | Uninstall script failed |
1 | Dev server token provided (no longer supported) |
N | Custom exit code from --wait (reflects editing) |
--wait, the exit code reflects the success of the editing session
as determined by Zed.
Environment Variables
EDITOR
Set Zed as the default editor:
VISUAL
Set Zed as the visual editor:
ZED_UPDATE_EXPLANATION (Internal)
Used internally to customize update messages (e.g., for Flatpak installations).
FORCE_CLI_MODE_ENV_VAR_NAME (Internal)
Used internally to force CLI mode when launching Zed.
XDG_DATA_HOME (Linux)
Controls the default location for user data on Linux. If not set, defaults to
~/.local/share.
Examples
Basic Usage
With Options
Complex Commands
Integration with Tools
See Also
- CLI Overview - Introduction and installation
- Open Command - Detailed documentation on opening files
- Diff Command - Detailed documentation on diff mode
