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=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 25994 invoked from network); 12 Jan 2021 16:50:47 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 12 Jan 2021 16:50:47 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1610470247; b=Lvvq+0SJPDxJC1vT7v5L8pxuPcjR1MvZWbZoxKQlM6QV9DV6K8c1xZUfD/vubg+WexFDXIqbQ8 FS69Yvi+yX5OCv+naM+u2x5l89aQuPpMDTkg36XrdXOIDbW2B+UYuaPn/w6MXXDPhbkIvXuP2f lCjh4hS9qklRvxKCAeY5RGL8kYs/hCHIltlAGCYHRRxo63FJ3pa7m+T2PlIQHTFlm1LsKeMYFc Dg8WH7bQ8/SOfkYLB/MR3YZ9EtxsITt0lT9Q+eFodCIvzVYmsXSY7PApvrPW5plw5OWwISlPGd pJWKtRzp0hUw5Ujy93nQByOIzbmwBneN3ma1B3vb9f3x9w==; 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=1610470247; bh=znyCBob9z9voMC+ldtwY7p2okC1KzlNTKzQVhd1wCAc=; 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=I09fw8ngQXo2BhRO7RfbbAtpbyVwhlUfOwwYGxKQv0Ioqe75dFxfEjVNyqZJ4Q150ScHrIA0oc EUxUEsiaMyq6LwiuVM9svFzB8VQJp4rYDx/Pa8ByI6CDs3v6ndc8ipd5OznpLn17ylPPj+sqwm bZ0C42SV9uO9DOGJpC6rcXuOsv1Ox6ZX/NmmGlY41gBHx1nTNtS9gTpLFX7gye2j9DpSEkqToP vF74+rM78uDM8Hx1JAZk8iz45Zg9Hqo/+c3PiY0qaNEiRe2X0NrRmpz25poV4jhWMatz1jVn3+ qLBQO2wT2RMQMpHY/zWe9bBahRAYpdjuvEqemQyVwg736A==; 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=Gv0UPlreD8nHXVWKa83l0LNX1WhS2aD9cMCAYfskA/0=; b=XFJ9vjZ5LtXpvG2o85SuQzMYjc mxxdVpq6zS1wZY8HJUFgVVnj3i17HIsaxs69UIZQ1oLW7+AuryEHqY+wH6iYcMUbVluM8E+RsfvgB PPD6St1AuKglvA1chF7ujPeE3P9AdG8Yi9IJHmphmjAvQjaL3Smu11wH+LoGYOv7gsj/XPtR0GjHN GV73b2wcgC588jzhQep+OMQalrLvzA7JkH/UY9oZ3Ntue20u+744hN+ldvFYyzvVWthijY1Q1Xcde FLuQ9aVKkcy4hQKl49OxSVUR6kd0fQke+QGzYD3xllEf9sJIHXozqj2pY0MWubs0EyE5RwGIWVvcs U6uiqCvA==; Received: from authenticated user by zero.zsh.org with local id 1kzMsX-0001OT-5Z; Tue, 12 Jan 2021 16:50:45 +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]:27363) by zero.zsh.org with utf8esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kzMps-0000xz-LI; Tue, 12 Jan 2021 16:48:03 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=klanderman.net; q=dns/txt; s=mg; t=1610470082; h=Content-Type: MIME-Version: References: Message-ID: In-Reply-To: Date: Reply-To: Subject: To: From: Sender; bh=Gv0UPlreD8nHXVWKa83l0LNX1WhS2aD9cMCAYfskA/0=; b=NYxCRTXkxAR8OGGtwf+x45eJ0nuktGFsnPMGAQAPFvkPWxw9MmKE3+Il5uWNNpfCjXx11CpK BoyInsUkQjjVkQAgB/zQ2x1P67G7OqZtPhIkPfylNOya1gRkHyCaRUshu8j0l5LPK2ie5sQu txUjEWfvKqOD7o2mHCH0Rb6IR4U= 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-n08.prod.us-west-2.postgun.com with SMTP id 5ffdd2bc2a47972bcca90064 (version=TLS1.3, cipher=TLS_AES_128_GCM_SHA256); Tue, 12 Jan 2021 16:47:56 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 953F3415EA; Tue, 12 Jan 2021 11:47:55 -0500 (EST) Received: by lwm.klanderman.net (Postfix, from userid 1000) id 4FA8129E2974; Tue, 12 Jan 2021 11:47:55 -0500 (EST) From: Greg Klanderman To: zsh-users@zsh.org Subject: Re: additionally saving history for each directory? Reply-To: Greg Klanderman Date: Tue, 12 Jan 2021 11:47:55 -0500 In-Reply-To: <877dp9omok.fsf@lwm.klanderman.net> (Greg Klanderman's message of "Tue, 22 Dec 2020 11:00:43 -0500") Message-ID: <878s8yksp0.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> <877dp9omok.fsf@lwm.klanderman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Validation-by: kb@spambri.de X-Seq: 26375 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: >>>>> On December 22, 2020 Greg Klanderman wrote: > 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'} > } Hi all, realize this probably got overlooked during the holidays.. should it work to do it this way as well as the suggestion in the zsh manual, i.e. zshaddhistory() { print -sr -- ${1%%$?\n?} fc -p .zsh_local_history } which prints to the normal history, then switches to the local history and relies on the normal save to save to the now default local history. My version is trying to write directly to the local history file from the hook, then allow the normal history save to go to the normal history file. My version is creating the local history file, but nothing gets written. The normal history is updated. Also if anyone has any key bindings for searching/traversing an alternate local history file please post! thanks, Greg > 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