zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: Automatic stdout/err redirection
Date: Sat, 11 Nov 2017 15:36:33 -0800	[thread overview]
Message-ID: <171111153633.ZM20254@torch.brasslantern.com> (raw)
In-Reply-To: <878tfc97d5.fsf@wavexx.thregr.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.


  reply	other threads:[~2017-11-11 23:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-11 15:12 Yuri D'Elia
2017-11-11 23:36 ` Bart Schaefer [this message]
2017-11-12 12:00 ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=171111153633.ZM20254@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).