From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12116 invoked by alias); 15 Dec 2014 17:05:37 -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: 19544 Received: (qmail 23395 invoked from network); 15 Dec 2014 17:05:35 -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=GimrVN/6WsQ2DPH0HW94dmQToEWV7AzGiUEaIDpne5Q=; b=d25QgTjo4rZv0iMqdGV00KdB62DpNjlnYYizhrbqgSN91hAUCmmlWA7a9PXvISLByQ +iW1DIxPA1suLcQZ4yn3Z/z2wuSxTLzofe6daS5NtAMuajagowbK/39jgk1qnwbwqKr3 rWXoWff9QpJH8SdJoRGXTrNbUUXVlxlHcZMXO5VigWYfQqwwI5QJEa0Ik9kMANdddmU/ xdbcmVLIpm0lv8UFIftmxFOYAmedfk713MgAmqmLmVvSZaptTQAKCty6ibNgR0H5sKfq WPVVZMuMw7abrRvKPVNj7T1AzUcbTdqOsB1o1YNuU9Hr/9GNtOBEKHeEuLLii2KRzRLw jYwg== MIME-Version: 1.0 X-Received: by 10.180.218.74 with SMTP id pe10mr33443130wic.48.1418663130291; Mon, 15 Dec 2014 09:05:30 -0800 (PST) Sender: rocky.bernstein@gmail.com In-Reply-To: <141215081440.ZM25053@torch.brasslantern.com> References: <141214185332.ZM24112@torch.brasslantern.com> <141215003717.ZM24212@torch.brasslantern.com> <141215081440.ZM25053@torch.brasslantern.com> Date: Mon, 15 Dec 2014 12:05:30 -0500 X-Google-Sender-Auth: 9odlVcusS5gVl8nEe_dkYj4tTYw 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=001a1134d57aefe497050a443fa2 --001a1134d57aefe497050a443fa2 Content-Type: text/plain; charset=UTF-8 Making the change suggested, adding 1000 doesn't change the behavior - no file is written. Again, here is the entire 12-line 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 # The -s option below adds the line to the history print -s $line line='' done As to reading docs, I've gone over http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html and http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System-Configuration and https://github.com/johan/zsh/blob/master/Functions/Misc/sticky-note way more times than I want or normally have to do to get corresponding information in programming systems. And still without success. In the first doc for built-in commands, 1000, the histsize parameter is optional and is taken from HISTSIZE and SAVEHIST if those parameters are not given. My HISTSIZE and SAVEHIST are 1000. What is sorely missing, and I've also looked at http://zsh.sourceforge.net/Guide/zshguide.html, are some *SIMPLE* examples like the program above. In fact it would be great if a corrected version of the above could be included in the User Guide. When the basic history mechanism isn't working, it doesn't help to pour over a 138-line program that performs several functions in one program, adds key bindings, beeps at the terminal, has color themes, and uses some sort of "{ } aways { }" construct that probably is a Zsh extension and not POSIX shell construct. That program is a great as an example of a finished zsh program. But for learning purposes, even variable interpolation as in fc -ap $stickyfile $stickysize $stickysize instead of: fc -ap /tmp/example_history 1000 is a distraction. is a distraction. On Mon, Dec 15, 2014 at 11:14 AM, Bart Schaefer wrote: > On Dec 15, 9:26am, Rocky Bernstein wrote: > } > } 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*. > > I don't really mind helping you out here, but if you were to actually > read the documentation for the "fc" command or even look more closely > at the way it's used in sticky-note you should be able to figure this > out for yourself. > > } #!/usr/bin/zsh > } fc -ap /tmp/example_history 1000 > > You need to supply another argument to "fc -ap" telling it what the > maximum size of the saved file is. Then that number of lines will > be saved automatically when the current function goes out of scope. > --001a1134d57aefe497050a443fa2--