From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13086 invoked by alias); 15 Dec 2014 14:26:28 -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: X-Seq: 19541 Received: (qmail 13136 invoked from network); 15 Dec 2014 14:26:25 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=oyeZUKdZpaEIkVAveyRHiE//mjTXo74uZDvbtANWDuQ=; b=PfIi9QUug3KhOmNdmQ6Yt//b3B+Rbn0bSFR4Ov9cclRAImthlgMWKEH/+0qRnOPUVn XFVSwC8hB4CIGbQAkLblPWkUhD2h6l6Ss8uynCm/Cilv7qZ4OmmDLm4JFm5AzHBaSJjE g9erPrJFWtoH0GNRAWuuNBVB3Bcjsyodw+FKamKyC8fjnpgcYQMRMDuxjD9nejNzQqxC 95TF+9dZp2SGaBZjm0z2MqjqKjh3Q0rgtm8ejaCfMyywWcl9jBmcgzxaOoK0lSFbSEvu PJywPq7oCJnGRH+uGyQY18sYyoH9ZDRW3I95tIBYnWkOiPm4ruYIYRDWbhRLPy1DAk2n XNWA== MIME-Version: 1.0 X-Received: by 10.180.109.3 with SMTP id ho3mr31963134wib.39.1418653581779; Mon, 15 Dec 2014 06:26:21 -0800 (PST) Sender: rocky.bernstein@gmail.com In-Reply-To: <141215003717.ZM24212@torch.brasslantern.com> References: <141214185332.ZM24112@torch.brasslantern.com> <141215003717.ZM24212@torch.brasslantern.com> Date: Mon, 15 Dec 2014 09:26:21 -0500 X-Google-Sender-Auth: 1tgUbN-ps6-1cFGbbnbp93N3UvM Message-ID: Subject: Re: An example of writing a custom history file? From: Rocky Bernstein To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=e89a8f3b9dafcd2707050a42062c --e89a8f3b9dafcd2707050a42062c Content-Type: text/plain; charset=UTF-8 Almost there! The only remaining problem is now how write the accumulated history. For that, I assume I use fc -W *filename* or fc -A *filename*. But this isn't working. Here is the corrected simple program: #!/usr/bin/zsh fc -ap /tmp/example_history 1000 local line # Read lines and add them to history while vared -h -p "hey: " line do [[ $line == 'quit' ]] && exit 0 fc -p /tmp/example_history 1000 # The -s option below adds the line to the history print -s $line line='' done fc -W /tmp/example_history I have also tried putting "fc -A" as well and tried putting the write command inside the loop. Again, thank you. On Mon, Dec 15, 2014 at 3:37 AM, Bart Schaefer wrote: > On Dec 15, 2:09am, Rocky Bernstein wrote: > } > } Thanks for the pointer. That program is too complicated and there is too > } much going on for me to understand which parts add to the history file. > I'm > } guessing it has something to do with the > } zle .push-line. > > Well, no, it doesn't have anything to do with that at all. > > } Here is the 138 line program boiled down to less than 10, the parts I'd > } like to focus on: > } > } #!/usr/bin/zsh > } fc -ap /tmp/example_history 1000 > } # Read lines and add them to history > } local sticky > } while vared -h -p "hey: " sticky > } do > } print $sticky > } sticky='' > } done > > You've missed the important bit, which is the -s option to print. THAT > is what adds lines to the history. > > I probably should have pointed you to the example zshaddhistory hook in > the documentation. > > } Additionally what I would like to do in the body of the loop decide > whether > } or not to add this to the history. > > # Pseudo-code > if this_line should be added to the history > then print -sR "$this_line" > fi > > --e89a8f3b9dafcd2707050a42062c--