diff --git a/docs/src/SUMMARY.md b/docs/src/SUMMARY.md index d0605f34475e47ca273c183cf2c334ed87ceb8fe..a4a0d420c1d7a9ccc042d1e063f3faf9fee568ef 100644 --- a/docs/src/SUMMARY.md +++ b/docs/src/SUMMARY.md @@ -174,9 +174,7 @@ - [All Settings](./reference/all-settings.md) - [All Actions](./all-actions.md) -- [CLI Reference](./command-line-interface.md) -- [Environment Variables](./environment.md) -- [Glob Patterns](./globs.md) +- [CLI Reference](./reference/cli.md) # Account & Privacy diff --git a/docs/src/command-line-interface.md b/docs/src/command-line-interface.md index 1a7831811dd119357c7f076be3fe9efa35bce021..876ac6e30b45bb6af8aba4af54ba00b31ebb8972 100644 --- a/docs/src/command-line-interface.md +++ b/docs/src/command-line-interface.md @@ -1,18 +1,3 @@ -# Command-line Interface +# Command-Line Interface -Zed has a CLI, on Linux this should come with the distribution's Zed package (binary name can vary from distribution to distribution, `zed` will be used later for brevity). -For macOS, the CLI comes in the same package with the editor binary, and could be installed into the system with the `cli: install` Zed command which will create a symlink to the `/usr/local/bin/zed`. -It can also be built from source out of the `cli` crate in this repository. - -Use `zed --help` to see the full list of capabilities. -General highlights: - -- Opening another empty Zed window: `zed` - -- Opening a file or directory in Zed: `zed /path/to/entry` (use `-n` to open in the new window) - -- Reading from stdin: `ps axf | zed -` - -- Starting Zed with logs in the terminal: `zed --foreground` - -- Uninstalling Zed and all its related files: `zed --uninstall` +This page has moved to the [CLI Reference](./reference/cli.md). diff --git a/docs/src/macos.md b/docs/src/macos.md index 5ebc037697934857d75f1b60177dcc0cd8e49393..cfabe381905fcac11687b5a5f5814111801e566d 100644 --- a/docs/src/macos.md +++ b/docs/src/macos.md @@ -113,6 +113,6 @@ If Zed uses more resources than expected: 1. Check for runaway language servers in the terminal output (`zed: open log`) 2. Try disabling extensions one by one to identify conflicts -3. For large projects, consider using [project settings](./configuring-zed.md) to exclude unnecessary folders from indexing +3. For large projects, consider using [project settings](./reference/all-settings.md#file-scan-exclusions) to exclude unnecessary folders from indexing For additional help, see the [Troubleshooting guide](./troubleshooting.md) or visit the [Zed Discord](https://discord.gg/zed-community). diff --git a/docs/src/reference/cli.md b/docs/src/reference/cli.md index c31a0bc9382af88dbd76cb70d16187225b18a0e9..1b5b979a5faa700bbf6b12667fc27364488a55ac 100644 --- a/docs/src/reference/cli.md +++ b/docs/src/reference/cli.md @@ -1 +1,191 @@ # CLI Reference + +Zed includes a command-line interface (CLI) for opening files and directories, integrating with other tools, and controlling Zed from scripts. + +## Installation + +**macOS:** Run the `cli: install` command from the command palette ({#kb command_palette::Toggle}) 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 (commonly `zed` or `zeditor`). + +**Windows:** The CLI is included with Zed. Add Zed's installation directory to your PATH, or use the full path to `zed.exe`. + +## Usage + +```sh +zed [OPTIONS] [PATHS]... +``` + +## Opening Files and Directories + +Open a file: + +```sh +zed myfile.txt +``` + +Open a directory as a workspace: + +```sh +zed ~/projects/myproject +``` + +Open multiple files or directories: + +```sh +zed file1.txt file2.txt ~/projects/myproject +``` + +Open a file at a specific line and column: + +```sh +zed myfile.txt:42 # Open at line 42 +zed myfile.txt:42:10 # Open at line 42, column 10 +``` + +## Options + +### `-w`, `--wait` + +Wait for all opened files to be closed before the CLI exits. When opening a directory, waits until the window is closed. + +This is useful for integrating Zed with tools that expect an editor to block until editing is complete (e.g., `git commit`): + +```sh +export EDITOR="zed --wait" +git commit # Opens Zed and waits for you to close the commit message file +``` + +### `-n`, `--new` + +Open paths in a new workspace window, even if the paths are already open in an existing window: + +```sh +zed -n ~/projects/myproject +``` + +### `-a`, `--add` + +Add paths to the currently focused workspace instead of opening a new window: + +```sh +zed -a newfile.txt +``` + +### `-r`, `--reuse` + +Reuse an existing window, replacing its current workspace with the new paths: + +```sh +zed -r ~/projects/different-project +``` + +### `--diff ` + +Open a diff view comparing two files. Can be specified multiple times: + +```sh +zed --diff file1.txt file2.txt +zed --diff old.rs new.rs --diff old2.rs new2.rs +``` + +### `--foreground` + +Run Zed in the foreground, keeping the terminal attached. Useful for debugging: + +```sh +zed --foreground +``` + +### `--user-data-dir ` + +Use a custom directory for all user data (database, extensions, logs) instead of the default location: + +```sh +zed --user-data-dir ~/.zed-custom +``` + +Default locations: + +- **macOS:** `~/Library/Application Support/Zed` +- **Linux:** `$XDG_DATA_HOME/zed` (typically `~/.local/share/zed`) +- **Windows:** `%LOCALAPPDATA%\Zed` + +### `-v`, `--version` + +Print Zed's version and exit: + +```sh +zed --version +``` + +### `--uninstall` + +Uninstall Zed and remove all related files (macOS and Linux only): + +```sh +zed --uninstall +``` + +### `--zed ` + +Specify a custom path to the Zed application or binary: + +```sh +zed --zed /path/to/Zed.app myfile.txt +``` + +## Reading from Standard Input + +Read content from stdin by passing `-` as the path: + +```sh +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 Handling + +The CLI can open `zed://`, `http://`, and `https://` URLs: + +```sh +zed zed://settings +zed https://github.com/zed-industries/zed +``` + +## Using Zed as Your Default Editor + +Set Zed as your default editor for Git and other tools: + +```sh +export EDITOR="zed --wait" +export VISUAL="zed --wait" +``` + +Add these lines to your shell configuration file (e.g., `~/.bashrc`, `~/.zshrc`). + +## macOS: Switching Release Channels + +On macOS, you can launch a specific release channel by passing the channel name as the first argument: + +```sh +zed --stable myfile.txt +zed --preview myfile.txt +zed --nightly myfile.txt +``` + +## WSL Integration (Windows) + +On Windows, the CLI supports opening paths from WSL distributions. This is handled automatically when launching Zed from within WSL. + +## Exit Codes + +| Code | Meaning | +|------|---------| +| `0` | Success | +| `1` | Error (details printed to stderr) | + +When using `--wait`, the exit code reflects whether the files were saved before closing. diff --git a/docs/src/reference/environment-variables.md b/docs/src/reference/environment-variables.md deleted file mode 100644 index 1d535f22b038fbe3dc1a0b679571dcb0b8df59e0..0000000000000000000000000000000000000000 --- a/docs/src/reference/environment-variables.md +++ /dev/null @@ -1 +0,0 @@ -# Environment Variables diff --git a/docs/src/reference/glob-patterns.md b/docs/src/reference/glob-patterns.md deleted file mode 100644 index 605fa295c187e1d60b1a91b74f114419da89ed2e..0000000000000000000000000000000000000000 --- a/docs/src/reference/glob-patterns.md +++ /dev/null @@ -1 +0,0 @@ -# Glob Patterns