Opening Files and Projects
The Zed CLI provides flexible options for opening files and directories, controlling how they are added to workspaces, and managing multiple windows.Basic File Opening
Open a single file:Opening Directories
Open a directory as a workspace:Line and Column Positioning
Open a file at a specific line:PathWithPosition format and works with:
- Absolute paths:
/home/user/file.txt:10:5 - Relative paths:
src/main.rs:42 - Paths that don’t exist yet:
newfile.txt:1
Workspace Management
New Window (-n, --new)
Create a new workspace window, even if the paths are already open:
Add to Current Workspace (-a, --add)
Add paths to the currently focused workspace:
Reuse Window (-r, --reuse)
Replace the current workspace with new paths:
Flag Interaction
The workspace management flags override each other:--new,--add, and--reuseare mutually exclusive- The last specified flag takes precedence
- Without any flag, Zed uses its default behavior (open in new window or reuse based on settings)
Waiting for Closure (-w, --wait)
Wait for all opened files to be closed before the CLI exits:
- For files: waits until all specified files are closed
- For directories: waits until the created window is closed
- Exit code reflects success of the editing session
Reading from Standard Input
Read content from stdin:- argument must be the only path argument. Zed creates a temporary file
with the stdin content and opens it.
Anonymous File Descriptors
On Linux, macOS, and FreeBSD, Zed supports reading from anonymous file descriptors: Linux:memfd: anonymous files.
macOS and FreeBSD:
URL Opening
Open URLs directly:zed://- Zed-specific URLshttp://andhttps://- Web URLsfile://- Local file URLsssh://- SSH remote paths
Windows: WSL Integration
On Windows, the CLI automatically handles paths from WSL distributions. When launching Zed from within WSL, paths are converted tofile:// URLs with the
WSL path resolved.
The --wsl flag is used internally and should not be set manually.
Custom User Data Directory
Open files with a custom data directory:- Database
- Extensions
- Logs
- Settings
- macOS:
~/Library/Application Support/Zed - Linux:
$XDG_DATA_HOME/zed(typically~/.local/share/zed) - Windows:
%LOCALAPPDATA%\Zed
Foreground Mode
Run Zed in the foreground, keeping the terminal attached:- Debugging startup issues
- Viewing log output in real-time
- Running Zed in a terminal-based workflow
Custom Zed Binary
Specify a custom path to the Zed application or binary:- Use a development build
- Run multiple Zed versions
- Use a custom installation location
Examples
Edit a Git commit message:See Also
- CLI Overview - Introduction and installation
- Diff Command - Comparing files
- CLI Options - Complete reference for all flags
