Zsh Mailing List Archive
Messages sorted by:
Re: Automatic stdout/err redirection
- X-seq: zsh-workers 42014
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Automatic stdout/err redirection
- Date: Sat, 11 Nov 2017 15:36:33 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=/bedBAP4lLXzdk2Jk/XmX46UwTHtaurNdVUHJGOD5fY=; b=XzUbt5n9cCNFP7ePSkTuWqIbgUZSfnaSvn53W/DFqIx0lgV14XHWPtN/hpOi4Xoqry OdL1EcVLK4WIIwq27oCyZTGNK6Optl9EhIVZa29cQqtHu8kEfuDJhdB8r2CUdDw5VqJS 69TpeVVN+pAkYNxXoI2Au6oAtfdjwgQJ23yZVDVacmRHWKpsqVvhQSHyA7GOzm0Y13oQ lDZPnohmJI4U9s+t4KG4Bb/9wSxxM357Ix8DsZOPopsqOSQDDWufS6nkMuGhJ+NWKHsz nVbER6ZI3LigSpEHt+wnvvtEsE1UvgQ1HeR+X4exuHt6OAaXW6vIhkYbN5LKuUWjfwIc z9zA==
- In-reply-to: <firstname.lastname@example.org>
- List-help: <mailto:email@example.com>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:firstname.lastname@example.org>
- List-unsubscribe: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <firstname.lastname@example.org>
On Nov 11, 4:12pm, Yuri D'Elia wrote:
} I've been thinking for a while about the ability to manipulate the
} output of the previous command without executing it again. It's such a
} common occurrence...
} Just as a general opinion, what would you think about the behavior?
This has come up before and for practical purposes it just doesn't work
to try to build this into the shell, not least because of the trouble
you called out with interactive or "fullscreen" commands like editors.
It's also what the script(1) command is expressly designed for.
There are a couple of possible approaches:
1. Run your entire zsh session inside "script", capturing everything to
the same file. Use preexec and precmd to output boundary markers so
that the typescript file can be sliced up later into the output of
individiual commands vs. the output of the shell between commands, and
have widgets or other functions to selectively grab the previous output.
2. Use preexec or an accept-line wrapper or zle-line-finish hook to run
each command inside "script -c '...'". This gets tricky as you have to
differentiate external commands from shell builtins in order to avoid
breaking the semantics of assignments etc., and loops or if/else are a
difficult problem to address.
You could also write your own "script"-alike using zpty, but that would
end up looking very much like option #1 above, I think. With #1 you
could even have the typescript file accessible through the zsh/mapfile
module for access to the sections.
Messages sorted by: