zed
zed copied to clipboard
Zed fails to open new window for current directory if Zed is already running
Summary
Zed fails to start a new window when launching from a terminal if Zed is already running.
Steps to trigger the problem:
- Start Zed.
- In a terminal navigate to a directory to open in zed and issue the following command
zed ./.
Actual Behavior:
$ zed ./
zed is already running
Expected Behavior:
Expectation is to launch a new window opening up the current directory. Similar to the way code . works for Visual Studio Code.
Zed Version and System Specs
$ zed --system-specs
Zed System Specs (from CLI):
Zed: v0.180.2 (Zed)
OS: macOS 15.3.2
Memory: 32 GiB
Architecture: x86_64
You can try using zed -n path/to/file which should fix it (I believe thats what your trying to do?)
Also, what you seem to have specified is working completely fine for me, could you give a more accurate recreation?
Zed had been updated since this was posted:
$ zed --system-specs
Zed System Specs (from CLI):
Zed: v0.181.6 (Zed)
OS: macOS 15.4.0
Memory: 32 GiB
Architecture: x86_64
I'm trying to open the current directory into the editor the same way I can with code ., subl . atom .. There looks to be no -n parameter.
Current directory attempt:
$ zed -n ./
error: unexpected argument '-n' found
tip: to pass '-n' as a value, use '-- -n'
Usage: zed [OPTIONS] [PATHS_OR_URLS]...
For more information, try '--help'.
Single file attempt:
$ ls -la
Permissions Size User Date Modified Name
drwxr-xr-x - davidh 21 Oct 2024 config
drwxr-xr-x - davidh 16 Aug 2023 pkg
.rw-r--r-- 361 davidh 30 Apr 2024 catalog-info.yaml
.rw-r--r-- 55 davidh 2 Feb 2024 DEVELOPMENT.md
.rw-r--r-- 24 davidh 2 Feb 2024 README.md
$ zed -n ./README.md
error: unexpected argument '-n' found
tip: to pass '-n' as a value, use '-- -n'
Usage: zed [OPTIONS] [PATHS_OR_URLS]...
For more information, try '--help'.
If Zed is not running this does work, however it hijacks the terminal and does not release the terminal back in the similar manner as Code or Sublime.
$ zed ./
[2025-04-11T17:24:13-04:00 ERROR Users] expected value at line 1 column 1
If Zed is already running and I would like to open a new directory into a new window, this does not work.
$ zed ./
zed is already running
The following bash function seems to work on macOS. It will open in a new Zed window if a window is already running, or launch Zed fresh if Zed is not running.
Add the following to ~/.bashrc and source it. Update the path to the zed binary if different.
zed() {
if [[ $# -eq 0 ]]; then
open -a /usr/local/bin/zed .
else
for arg in "$@"; do
open -a /usr/local/bin/zed "$arg"
done
fi
}
Maybe it was a one-off bug in that specific release, but as of 0.182.11:
The Zed CLI binary.
This CLI is a separate binary that invokes Zed.
Examples:
`zed`
Simply opens Zed
`zed --foreground`
Runs in foreground (shows all logs)
`zed path-to-your-project`
Open your project in Zed
`zed -n path-to-file `
Open file/folder in a new window
Usage: zeditor [OPTIONS] [PATHS_WITH_POSITION]...
Arguments:
[PATHS_WITH_POSITION]...
The paths to open in Zed (space-separated).
Use `path:line:column` syntax to open a file at the given line and column.
Options:
-w, --wait
Wait for all of the given paths to be opened/closed before exiting
-a, --add
Add files to the currently open workspace
-n, --new
Create a new workspace
--user-data-dir <DIR>
Sets a custom directory for all user data (e.g., database, extensions, logs). This overrides the
default platform-specific data directory location. On macOS, the default is
`~/Library/Application Support/Zed`. On Linux/FreeBSD, the default is `$XDG_DATA_HOME/zed`. On
Windows, the default is `%LOCALAPPDATA%\Zed`
-v, --version
Print Zed's version and the app path
--foreground
Run zed in the foreground (useful for debugging)
--zed <ZED>
Custom path to Zed.app or the zed binary
--dev-server-token <DEV_SERVER_TOKEN>
Run zed in dev-server mode
--system-specs
Not supported in Zed CLI, only supported on Zed binary Will attempt to give the correct command
to run
-h, --help
Print help (see a summary with '-h')
To read from stdin, append '-', e.g. 'ps axf | zed -'
And using zed -n . opens a new window, even if there are other Zed editors open to the same or different projects.
The -n flag is what you're looking for @davidhooey, it's just not present in the Zed binary, only for the CLI, hence the confusion
The issue is that you are confusing the two zed entrypoints:
/Applications/Zed.app/Contents/MacOS/cli
/Applications/Zed.app/Contents/MacOS/zed
You should be exclusively using the former from the terminal. If there is a running Zed instance, it will reuse that, if not, it will spawn one and use that.
It's a little confusing because we recommend folks alias/symlink cli into their path as zed. This is what the cli: install action does from the welcome screen.
You can check your current config with: command -v zed and if it's a symlink use readlink $(which zed) to see where the symlink points.
On Linux it's:
~/.local/zed.app/libexec/zed-editor
~/.local/zed.app/libexec/zed