zed
zed copied to clipboard
Support for reading from stdin
Check for existing issues
- [X] Completed
Describe the feature
Have -
flag in zed CLI which allows reading from stdin:
Example:
ps auxf | zed -
Currently, zed -
just opens the editor with -
as filename.
If applicable, add mockups / screenshots to help present your vision of the feature
No response
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)'