zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: [PATCH] Per-directory history implementation
Date: Tue, 28 Jan 2020 09:30:32 +0100	[thread overview]
Message-ID: <20200128083032.GA108025@zira.vinc17.org> (raw)
In-Reply-To: <20200117164621.2954-1-alonid@gmail.com>

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 <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

      reply	other threads:[~2020-01-28  8:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-17 16:46 Dan Aloni
2020-01-28  8:30 ` Vincent Lefevre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200128083032.GA108025@zira.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).