From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id a05899c2 for ; Tue, 8 Jan 2019 15:43:29 +0000 (UTC) Received: (qmail 16603 invoked by alias); 8 Jan 2019 15:43:15 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23832 Received: (qmail 29957 invoked by uid 1010); 8 Jan 2019 15:43:15 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.100.2/25112. spamassassin: 3.4.2. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 0.868871 secs); 08 Jan 2019 15:43:15 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=message-id:from:to:mime-version :content-transfer-encoding:content-type:date:in-reply-to :references:subject; s=fm2; bh=YnjARaJsB6jt3KKfSjcWHB2GZXkgyZHW0 h0gHITud48=; b=NqOJXnNOGktq5rM0vr1Pz8t90M0wQheWkAwtIZu3pdsJR6tk0 qd6UIIDsAZrYikdFnqGv29xOBfGurP5FYe2lRFPOANcA+08KG4BpvbuLo9c3CCcI WOWTy4/HMZ9RxguXGkfPMVixmc/MHxd7YbnztJgslafAkHR+Xku+wyBErvBLut3z W+iKzAnq6adG6DuRzkU/INnqJWyb1/0swWYI1cV/9GTOna8HZvsstBKF4fN5f+rx RqiHugBPnHO8C0Us0PidApipnC3D80n0UeVmhMw9RpMZaqsBwFqvHkbsKc0FgZ/g wSihONsswVNxQ+TN3NT0SDrXaYg17YJOYfyfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=YnjARaJsB6jt3KKfSjcWHB2GZXkgyZHW0h0gHITud 48=; b=hIkMr/Zwue1r3A9SwZQpag0UaGD9nFDQpznsVYR0e80Vk5EK6kWQMxDMZ db3BruDZ2htbZ5V+ib1NXiFcDFsLKe+T305bjlRBiwFktN/OkpdQlzmw8e5xkMEu /U34AuqCwkyDib48E+m0Cmk+21yg49PVz+fGfera9RenTQMEARUOiHq0hAxYNFl7 ryuq0EblOc/70rcf0CNy/1nY3xiUVSWcOy42Bw/pftL4TY3R77aoTR/M6YoDA/gG 5k9/Lzzj4Wr8ydq81aeRmVtfoUrgZHi9bQ8kvKyFe7IifvkVJjyH6+TAVvlA5Xt7 WbQTjbV8ZTtkk/AojVtSbLtyjqGOA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrvdelgdejjeculddtuddrgedtkedrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkffhvfgggfgtofffjghfufesthhqredtredtjeenucfhrhhomhepffgrnhhi vghlucfuhhgrhhgrfhcuoegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvgeqne cuffhomhgrihhnpeiishhhrdhorhhgnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhs segurghnihgvlhdrshhhrghhrghfrdhnrghmvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Message-Id: <1546962190.970784.1628862200.36C83046@webmail.messagingengine.com> From: Daniel Shahaf To: Francisco Borges , zsh-users@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-5ae1f753 Date: Tue, 08 Jan 2019 15:43:10 +0000 In-Reply-To: References: Subject: Re: Always save first N bytes of output from all commands? Francisco Borges wrote on Tue, 08 Jan 2019 15:53 +0100: > Is there an easy easy way to *always* save the (first N bytes) of the > output all commands? Or least save the output of the very last command? >=20 > Something like always having >=20 > | tee ~/.output_history/$TTY/${HISTCMD}.out >=20 > but ideally with a control over the number of bytes written. Is something > like that possible? >=20 > Right now I resort to insert-last-command-output function (original by pws > at http://www.zsh.org/mla/users/2005/msg00550.html while answering a > question of mine...). To re-execute a command and insert its output in the > command line. Sometimes it is fast enough and sometimes it is slow. I know > we have "keep" (./share/zsh/functions/keeper) distributed with Zsh itself, > but keep much like tee has to be manually inserted into the command itself > and that it becomes less awesome. You could wrap the accept-line widget with something along these lines: accept-line() { PREBUFFER=3D"{ $PREBUFFER"; BUFFER+=3D" }" BUFFER+=3D"| tee >(head -c 1024 > /path/to/file)" zle .accept-word -- "$@" } zle -N accept-line (untested) However, commands that check if their stdout isatty() (the C equivalent of =C2=AB[[ -t 1 ]]=C2=BB) will with this change think it's not a tty. ls(= 1) without arguments is the standard example of this. You could probably fix that by creating a pty, but I don't have an example of that. > I work on OSX and I bet I can write AppleScript code to... somehow fetch > the output and insert in the buffer but it I'd rather a (portable) > Zsh-based solution. >=20 > Any ideas other than going the AppleScript route? Cheers, Daniel