3 ms·
On most POSIX systems you can use fc(1) to edit a command in your $EDITOR. In vi(1) and friends you can then use "%!ls" to replace the contents of the buffer w
by ainar-g 6y ago
On most POSIX systems you can use fc(1) to edit a command in
your $EDITOR. In vi(1) and friends you can then use "%!ls"
to replace the contents of the buffer with directory listing
and edit the commands you want.
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/fc.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/f...
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/vi.html https://pubs.opengroup.org/onlinepubs/9699919799/utilities/v...
- RMPR 6y ago> you can then use "%!ls" to replace the contents of the buffer with directory listing and edit the commands you want. I often used :r !ls for that, thanks for the tip + it's shorter
- gpanders 6y agoNote that in general this is not a one-to-one replacement. `%!cmd` sends the current buffer contents to `cmd`’s stdin and replaces the buffer with `cmd`’s output. In the case of ‘ls’ this works since it doesn’t take anything on stdin
- Legogris 6y agoYou just improved my life. Thank you.
- throwanem 6y agoIn Emacs, you can do this by invoking shell-command-on-region, by default bound to C-u M-| - iirc if no region is active it replaces the buffer, but I rarely use it that way so I might be wrong about that. At worst, C-x h C-u M-| gets you there.
- skywal_l 6y agohuh! I've been working on posix systems for 20 years and I didn't know that...