From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 6ce95f05 for ; Tue, 28 Jan 2020 08:31:21 +0000 (UTC) Received: (qmail 25858 invoked by alias); 28 Jan 2020 08:31:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45348 Received: (qmail 12138 invoked by uid 1010); 28 Jan 2020 08:31:13 -0000 X-Qmail-Scanner-Diagnostics: from joooj.vinc17.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25703. spamassassin: 3.4.2. Clear:RC:0(155.133.131.76):SA:0(-1.9/5.0):. Processed in 1.704469 secs); 28 Jan 2020 08:31:13 -0000 X-Envelope-From: vincent@vinc17.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Tue, 28 Jan 2020 09:30:32 +0100 From: Vincent Lefevre To: zsh-workers@zsh.org Subject: Re: [PATCH] Per-directory history implementation Message-ID: <20200128083032.GA108025@zira.vinc17.org> Mail-Followup-To: zsh-workers@zsh.org References: <20200117164621.2954-1-alonid@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200117164621.2954-1-alonid@gmail.com> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.12.1+33 (6a74e24e) vl-117499 (2019-06-23) On 2020-01-17 18:46:21 +0200, Dan Aloni wrote: > This change is an attempt to implement this feature straight into zsh, > so that its entry pruning and history file locking logic cover it as > well. > > NOTE: There is external plugin that tries to implement this in the > following manner: 1) switching the history file with current directory > change to maintain a separate one, and reloading the zsh history each > time it happens 2) maintaining the global history file in addition. > While I wanted that plugin to work for me, it felt far from perfect and > its downsides were too great for me. What are these downsides? I think that a solution written purely in zsh would be cleaner and more flexible: * The user may want to change other things when switching directories. * The user may want to change the history on other occasions. Hook functions are nice for this kind of things. > This is a first version, so I'm guessing there's much to iron out. > > -- > > Conditional on the activation of the `extended_history` feature, these > changes implement a `histsavecwd` feature. The current directory of the > command is added to each command in the history file, in this manner: > > : 1579121354 /home/user:0;ls -l > > Instead of the old format: > > : 1579121354:0;ls -l > > In addition, the 'fc' commands get a '-c' option that filters out > commands not pertaining to the current directory. This can serve to > implement a command similar to `Ctrl-R` showing only the per-directory > history. > > Note that that pathnames that contain the ':' character are not > supported for now - these are expected to mess up history parsing. We > should escape the `:` character if we want to support them, or change > the format altogether. That's a security issue, as the user may want/need to switch to any directory, possibly belonging to other users. The format should be able to handle any possible pathname (including with \n characters). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)