From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16041 invoked by alias); 11 Nov 2017 23:42:58 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42014 Received: (qmail 3507 invoked by uid 1010); 11 Nov 2017 23:42:58 -0000 X-Qmail-Scanner-Diagnostics: from mail-pg0-f48.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.83.48):SA:0(-4.7/5.0):. Processed in 1.313469 secs); 11 Nov 2017 23:42:58 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=/bedBAP4lLXzdk2Jk/XmX46UwTHtaurNdVUHJGOD5fY=; b=JToDY0VsAJx0DTufBPYr0baBVoSjC1yvrWXHgNwFdPMw89z+G5TCZPhoEa83wzz8iM OKDjBIT9RT4M4r/S1ipdSK+smZTuwOKJzZ+8ZhTpMi4oNCD6L2TUMKnIOA3IjozHvjb2 ns05LVXOSIF1dflWhI5B80FGM2js/KZ2SNruqJ8aOpnyA5aiblRMGVyfPzFaU8lxjPDx mOhauDEsI8xLh3EUGowpxNkoa8xlPTGWzmu/kihqYaHLMbYF8jUu4U+59XjVpZYGKR4T vgORnrL63GubnUzpxJ4mF+arz4Ip0Uj0ACPzYrlRKSHb4aqtXSb8F6blPmhs8qLW89T2 8xKw== X-Gm-Message-State: AJaThX6AT34ZQQhu6UaOYZQIIeSsewLYy0GwnUl6vtNO6kj26uYFJvp5 zvUxwfCTtGi1M/m9Xr/bcosUEoGv X-Google-Smtp-Source: AGs4zMaRsY+Beb6RVaU833U6lzovcxZKnYTm9mzQNkpsKKlkjlXxtVam8mv4WuTqeorop0dLXg61jg== X-Received: by 10.84.218.72 with SMTP id f8mr4844083plm.143.1510443774440; Sat, 11 Nov 2017 15:42:54 -0800 (PST) From: Bart Schaefer Message-Id: <171111153633.ZM20254@torch.brasslantern.com> Date: Sat, 11 Nov 2017 15:36:33 -0800 In-Reply-To: <878tfc97d5.fsf@wavexx.thregr.org> Comments: In reply to "Yuri D'Elia" "Automatic stdout/err redirection" (Nov 11, 4:12pm) References: <878tfc97d5.fsf@wavexx.thregr.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Automatic stdout/err redirection MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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.