From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14796 invoked by alias); 27 Sep 2011 03:12:06 -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: 16436 Received: (qmail 9363 invoked from network); 27 Sep 2011 03:12:05 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at benizi.com does not designate permitted sender hosts) Date: Mon, 26 Sep 2011 23:01:47 -0400 (EDT) From: "Benjamin R. Haskell" To: Jay Levitt cc: zsh-users@zsh.org Subject: Re: zshaddhistory confusion In-Reply-To: Message-ID: References: User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII On Mon, 26 Sep 2011, Jay Levitt wrote: > In addition to my normal zsh history, I want to write to a > .zsh_history_detail file with comments showing date, pwd, etc. I'm > trying > > function zshaddhistory() { > print -sr -- ${1%%\n'} ${1%%\n'} -> ${1%%$'\n'} > fc -p .zsh_history_detail > print -sr "${1%%\n'} ### ${PWD} `date '+%Y-%m-%d %R'`" same here: missing $' before the \n' > } > > but it now > 1. writes what looks like a pid into .zsh_history, and > 2. puts both the normal AND the detailed history into .zsh_history_detail. > > I am probably misunderstanding the fairly terse zshaddhistory docs. > Any hints? It's mostly the missing syntax. But, you also somewhat counterintuitively also have to return 1, so that zsh doesn't append an implicit: print -sr -- "${1%%$'\n'}" If you return a true value, the shell thinks you've done what you want to do and that it should log the line normally. Also, I added ~/ (the example in the docs is to have a per-directory history file). zshaddhistory () { print -sr -- "${1%%$'\n'}" fc -p ~/.zsh_history_detail print -sr -- "${1%%$'\n'} ### ${PWD} $(date '+%Y-%m-%d %R')" return 1 } The following doesn't seem to work, though I'd have thought it would based on the documentation... zshaddhistory () { fc -p ~/.zsh_history_detail print -sr -- "${1%%$'\n'} ### ${PWD} $(date '+%Y-%m-%d %R')" fc -P } -- Best, Ben