Open tuladhar opened 1 year ago
strictly speaking, -
flag is not a requirement. I know that TextMate's mate
cli command detects stdin automagically and does the right thing without additional flags
I use this so frequently, e.g. with git diff | mate
or similar, this would be great to have.
Unfortunately, zed
can somehow not open anonymous FDs, so this workaround:
$ pzed() { cat <(cat); }
$ echo "foo" | pzed
foo
... does not work:
$ pzed() { zed <(cat); }
$ echo "foo" | pzed
error opening PathLikeWithPosition { path_like: "/dev/fd/11", row: None, column: None }: failed to read path after update
The only way I've found is to copy to a temp file first, like so:
$ pzed() { local fn=$(mktemp); cat >"$fn"; zed "$fn"; }
This can be turned into a script that dynamically detects stdin and adds it as an argument (works both in Bash and Zsh):
zed() {
local args=("$@")
if [[ ! -t 0 ]]; then
local tmp=$(mktemp)
cat >"$tmp"
args+=("$tmp")
fi
command zed "${args[@]}"
}
But it's not ideal with the tempfile creation etc.
I have the same issue. My workaround:
alias to_zed='(cat > /tmp/zed.tmp.txt && zed /tmp/zed.tmp.txt)'
Just a note that the failed to read path after update
error when trying to read from a /dev/fd/…
file originates in the worktree crate: https://github.com/zed-industries/zed/blob/c83d007138587d832c5ce3a13c8cb99913c016be/crates/worktree/src/worktree.rs#L1717
Check for existing issues
Describe the feature
Have
-
flag in zed CLI which allows reading from stdin:Example:
Currently,
zed -
just opens the editor with-
as filename.If applicable, add mockups / screenshots to help present your vision of the feature
No response