1# CLI Reference
2
3Zed includes a command-line interface for opening files, directories, and controlling the editor from your terminal.
4
5## Installation
6
7- **macOS**: Run `cli: install` from the command palette to create a symlink at `/usr/local/bin/zed`
8- **Linux**: The CLI is included with your distribution's Zed package (binary name may vary)
9
10## Usage
11
12```sh
13zed [OPTIONS] [PATHS...]
14```
15
16## Common Commands
17
18| Command | Description |
19|---------|-------------|
20| `zed` | Open an empty Zed window |
21| `zed .` | Open the current directory as a project |
22| `zed /path/to/file` | Open a specific file |
23| `zed /path/to/folder` | Open a folder as a project |
24| `zed file1.rs file2.rs` | Open multiple files |
25| `zed -n /path` | Open in a new window |
26| `ps aux \| zed -` | Read from stdin |
27
28## Options
29
30| Option | Description |
31|--------|-------------|
32| `-w`, `--wait` | Wait for all given paths to be opened/closed before exiting |
33| `-a`, `--add` | Add files to the currently open workspace |
34| `-n`, `--new` | Create a new workspace |
35| `-r`, `--reuse` | Reuse an existing window, replacing its workspace |
36| `-` | Read from stdin |
37| `--foreground` | Run Zed in the foreground (useful for debugging, shows all logs) |
38| `--zed <PATH>` | Custom path to Zed.app or the zed binary |
39| `--dev-server-token <TOKEN>` | Run Zed in dev-server mode with the given token |
40| `--diff <OLD_PATH> <NEW_PATH>` | Open a diff view comparing two files (can be used multiple times) |
41| `--user-data-dir <DIR>` | Set a custom directory for all user data (database, extensions, logs) |
42| `--uninstall` | Uninstall Zed and all related files (Linux/macOS only) |
43| `--version` | Print Zed's version and the app path |
44
45## Opening Files at a Specific Line
46
47You can open a file at a specific line and column:
48
49```sh
50zed /path/to/file:42 # Open at line 42
51zed /path/to/file:42:10 # Open at line 42, column 10
52```
53
54## Examples
55
56Open the current directory in Zed:
57
58```sh
59zed .
60```
61
62Open a file and wait for it to close (useful for Git commit messages):
63
64```sh
65GIT_EDITOR="zed -w" git commit
66```
67
68Pipe command output into Zed:
69
70```sh
71cat /var/log/system.log | zed -
72```
73
74Open multiple files in a new window:
75
76```sh
77zed -n src/main.rs src/lib.rs
78```
79
80Compare two files:
81
82```sh
83zed --diff old_version.rs new_version.rs
84```
85
86Add files to an existing workspace:
87
88```sh
89zed -a additional_file.rs
90```