For just capturing the output of a command, you can use:
r !somecommand
But if you want to filter a range of lines through an external filter with POSIX ed(1), you need some sort of temporary storage (whether a file, the system clipboard, a tmux buffer or whatever). There's no analog to
:10,20! rot13
offered by vi/vim.
Someone (can't find the post/author at the moment) did hack this functionality into ed, but it's a custom fork of POSIX functionality.
Depending on your platform, you might have xclip instead (similar functionality on X), pbcopy/pbpaste on OSX, or some similar tool on Wayland or Windows.
@ed1conf @buffet Sam runs just fine on Linux; I use it there daily (alongside Toronto qed). I think it has been ported to OpenBSD, FreeBSD, and even Windows.
It amuses me that people associate it only with Plan 9; it was originally written for ~9th edition Research Unix, before the Plan 9 project started. (I was there, and an early adopter.)
@Harka Won't work. That won't pass the contents of the buffer as input to !command. The contents of the buffer can either be piped into the command or piped out of it, but not both.
Toronto qed (descended from ed in the late 1970s, not the 1960s editor that inspired ed) has three commands for exchanging text with other programs: >command # send to command's standard input <command # receive from standard output |command # send to stdin, read from stdout, replacing original addressed lines
Of course > and | take an address range and < a single address, like w and r.
I use | quite often either in ed or in sam; latter written by the guy from whom I caught the qed bug.
Implementing | takes some thought to avoid deadlock if pipes fill and block. Qed does it by spawing a temporary process to do the writing, while the main process reads into the buffer.
ed(1) conference
in reply to Jonathan Lamothe • • •For just capturing the output of a command, you can use:
r !somecommandBut if you want to filter a range of lines through an external filter with POSIX
ed(1), you need some sort of temporary storage (whether a file, the system clipboard, atmuxbuffer or whatever). There's no analog to:10,20! rot13offered by
vi/vim.Someone (can't find the post/author at the moment) did hack this functionality into
ed, but it's a custom fork of POSIX functionality.Jonathan Lamothe likes this.
ClaudioM reshared this.
Jonathan Lamothe
in reply to ed(1) conference • •ed(1) conference
in reply to Jonathan Lamothe • • •Using temporary/transient storage can avoid the temp-file cleanup step though:
or
Ameliorates it by a wee bit, but still a hassle that I'd fix if I had a time machine
Jonathan Lamothe
in reply to ed(1) conference • •ed(1) conference
in reply to Jonathan Lamothe • • •xclipinstead (similar functionality on X),pbcopy/pbpasteon OSX, or some similar tool on Wayland or Windows.emilia microsystems likes this.
buffet, das
in reply to ed(1) conference • • •Jonathan Lamothe
in reply to buffet, das • •Norman Wilson
in reply to Jonathan Lamothe • • •@ed1conf @buffet Sam runs just fine on Linux; I use it there daily (alongside Toronto qed). I think it has been ported to OpenBSD, FreeBSD, and even Windows.
It amuses me that people associate it only with Plan 9; it was originally written for ~9th edition Research Unix, before the Plan 9 project started. (I was there, and an early adopter.)
Jonathan Lamothe likes this.
SirWumpus 🍁⚔️ 🛡️
in reply to Jonathan Lamothe • • •ednot that I know. Withex/vi/ehyes. They have pipe through command some region of the buffer or all of it, eg.!{fmt -w68Harka
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Harka • •!command. The contents of the buffer can either be piped into the command or piped out of it, but not both.Norman Wilson
in reply to Jonathan Lamothe • • •Toronto qed (descended from ed in the late 1970s, not the 1960s editor that inspired ed) has three commands for exchanging text with other programs:
>command # send to command's standard input
<command # receive from standard output
|command # send to stdin, read from stdout, replacing original addressed lines
Of course > and | take an address range and < a single address, like w and r.
I use | quite often either in ed or in sam; latter written by the guy from whom I caught the qed bug.
Implementing | takes some thought to avoid deadlock if pipes fill and block. Qed does it by spawing a temporary process to do the writing, while the main process reads into the buffer.
Jonathan Lamothe likes this.
Harka
in reply to Jonathan Lamothe • • •Jonathan Lamothe
in reply to Harka • •