From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4027 invoked from network); 22 Dec 2020 16:01:52 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 22 Dec 2020 16:01:52 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1608652912; b=CfWX968squEGEydD70I2NJ5jkQPV57byGmPSL8YwxdhrhODAO5s+cXYhG/qXZsa4UddJWbfeKX JCr1c4drvUSjdVnBJqFdFHYXo8IPdgdS+XT4he2ZQKmaTWJtceOFjzPgGSQid9TgMqHvJ3YjPb cMJFu9ShbGOyX34SHZ0yBRt0uwxJj5QEZ/hTwDF0ZXCAZoc9lsC64ujPIMVgU0e2VpKwJOl79e 2OxFlUNIS7fv3wPuw+mnK6SRwTPg694lWvAFg4fOq1La1sWnKPBN/KENnxsJn+L6O2UeaptVmy Y4oF6wZNsJsZ/cEZ7GWgpKxZm1oi+EdnLC76bjCNTB8P/g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (so254-31.mailgun.net) smtp.remote-ip=198.61.254.31; dkim=pass header.d=klanderman.net header.s=mg header.a=rsa-sha256; dmarc=none header.from=klanderman.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1608652912; bh=Dr1V1g0g9eL7Agaa115BLyupkbfKFpWMp2ITYn/36wg=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:MIME-Version:References:Message-ID:In-Reply-To: Date:Reply-To:Subject:To:From:DKIM-Signature:DKIM-Signature; b=Z+aW9h/mBD30f0o6SsNm7MsSRpd7LlXDWJLuC4YVkGCZ6XM1Cptmn2Qw4aWSYvpFPClnQS3fCM bF/jJlIqUQHD4GfliSr+D01RKm2Wi7MXodbdeo6myPtJTctLZ85+nI+z/oKC2kNbOWTcROCsLB XU9KQXe0GdjpHmEOBnP+Om9KoRRzCPSXBEDOPHlQd+crVCSE2qd3bo1VFskLaiL/UbabyvszZG dx54pODonBlXrabnTRGU6LG8xkpJu72jmnfrIFfDXWe7LF0IyuSuKaTua6iRFwyPj5UgIm3nyO R1BcW2F4y8lAOpU1A1b1q4LJht/m2pruyd9nh6SW3cR1eQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:MIME-Version:References: Message-ID:In-Reply-To:Date:Reply-To:Subject:To:From:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cpHVnw1V2qfE4W2iC4qqqtRxxes9qzoO7+D0oXB6mrk=; b=Jryx44WvarYbSYitXbbWlC+Rht 6BLpGgEsZFU5hKAmBuNjKOsosmKE5UeIIIAOGkBCDQJzYblEHDTirR5O3XgH9F8gWYr1p7mmXocfE Jr6vkgkgqPzqK56yYRSWbsY57BoHdw4v7zWXZEbs9tuUCTDtqn4UWQvTY6Y+iMYF/LxaSn7clxXe+ XKfTqzq67xJMUrDFm2s6pbx2dyzLCbFiRcRKovXjU1KJzz+DyHVhrGWxcOpeONmj8/oMJrIZ01AdI DbLNfOyJ9sQakQ1614CodHsiAkt8DGFCqYBX5QF5VCIOV3OgGi6vXzowevuFQc/6B/M31C6cRB4D4 I0kYj7Pg==; Received: from authenticated user by zero.zsh.org with local id 1krk6f-0007I3-JO; Tue, 22 Dec 2020 16:01:49 +0000 Authentication-Results: zsh.org; iprev=pass (so254-31.mailgun.net) smtp.remote-ip=198.61.254.31; dkim=pass header.d=klanderman.net header.s=mg header.a=rsa-sha256; dmarc=none header.from=klanderman.net; arc=none Received: from so254-31.mailgun.net ([198.61.254.31]:37665) by zero.zsh.org with utf8esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1krk65-0006vM-Q5; Tue, 22 Dec 2020 16:01:16 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=klanderman.net; q=dns/txt; s=mg; t=1608652876; h=Content-Type: MIME-Version: References: Message-ID: In-Reply-To: Date: Reply-To: Subject: To: From: Sender; bh=cpHVnw1V2qfE4W2iC4qqqtRxxes9qzoO7+D0oXB6mrk=; b=UhUx/5uSMyIR3HiIfwp4bx4KQeOQ/rdRs2/CXax9SnMH/5C9mh0xiOzPgsuHoDrwtfLcsMCS sYa6/7g0WVjx/Okv57vzQKrjcuK4v4mAi2PJLyD7HWl/9ZeV2SZAgq+e3F/AyH0DDni/OFnK EW6mjfb3JSPgH9XZg60O+PCLSHM= X-Mailgun-Sending-Ip: 198.61.254.31 X-Mailgun-Sid: WyIzOGFmNSIsICJ6c2gtdXNlcnNAenNoLm9yZyIsICI5N2RiZDgiXQ== Received: from smtp2.klanderman.net (smtp2.klanderman.net [142.93.10.110]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 5fe2182b120d248bb559a826 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Tue, 22 Dec 2020 16:00:43 GMT Received: from lwm.klanderman.net (pool-72-93-77-73.bstnma.fios.verizon.net [72.93.77.73]) by smtp2.klanderman.net (Postfix) with ESMTPSA id 6B546415E7; Tue, 22 Dec 2020 11:00:43 -0500 (EST) Received: by lwm.klanderman.net (Postfix, from userid 1000) id 1FC0029E3603; Tue, 22 Dec 2020 11:00:43 -0500 (EST) From: Greg Klanderman To: zsh-users@zsh.org Subject: Re: additionally saving history for each directory? Reply-To: Greg Klanderman Date: Tue, 22 Dec 2020 11:00:43 -0500 In-Reply-To: (Bart Schaefer's message of "Sun, 20 Dec 2020 14:32:59 -0800") Message-ID: <877dp9omok.fsf@lwm.klanderman.net> User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.24 (linux) References: <24543.52705.896312.857217@lwm.klanderman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Seq: 26255 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: Thanks Bart! >>>>> On December 20, 2020 Bart Schaefer wrote: > There's a patch set in workers/45326 that never got much review. I don't think that was it, but interesting.. > However, the very simple example is in the zsh documentation under > "zshaddhistory". Hmm maybe that's what I saw.. I had been browsing the zsh manual recently, though I thought there were also some example key bindings. So if I add a hook something like the following to zshaddhistory_functions: save_per_directory_history () { setopt localoptions incappendhistory fc -p -a .zsh_local_history 1000 print -sr -- ${1%%$'\n'} } that should also work? Seems a little cleaner to write to the per- directory history file from the hook, and rely on the normal history writing mechanism to write to the normal history. Should I 'return 0' to be sure that the normal history is updated, to guard against the off chance the print might return an error? Also in practice I'll write the local history to ~/.zsh-local-history/${PWD//\//##} or something like that to keep them all in one place and avoid littering the filesystem. So this will incur the cost of reading the per- directory history file on every command execution? Or does zsh internally cache some number of recent history file sets? Hmm I see the local history files getting created, but they are all empty and remain so as I run various commands. I added a print of $1 in the hook and it does contain the command being run as expected. What am I doing wrong? thank you, Greg