zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Matt Pharr <mmp@graphics.stanford.edu>, zsh-users@math.gatech.edu
Subject: Re: per-directory history?
Date: Fri, 11 Apr 1997 20:50:18 -0700	[thread overview]
Message-ID: <970411205018.ZM5596@candle.brasslantern.com> (raw)
In-Reply-To: Matt Pharr <mmp@graphics.stanford.edu> "per-directory history?" (Apr 11, 12:08pm)

On Apr 11, 12:08pm, Matt Pharr wrote:
} Subject: per-directory history?
} 
} I was thinking about the history stuff in zsh last night, and it struck me
} that it would be neat to have a per-directory history mechanism.
} 
} Is this easily done at the user level given zsh's current set of features?

Relatively easily, yes.  The main issues are security (avoid loading a
history left for you by someone malicious (though this isn't too bad as
the commands aren't actually executed)), collision-avoidance in shared
directories, and handling of non-writable directories.

The solution looks something like

    chpwd() {
	local ohistsize=$HISTSIZE
    	fc -W ~-/.history.$UID
	HISTSIZE=0		# Discard previous dir's history
	HISTSIZE=$ohistsize	# Prepare for new dir's history
	fc -R ./.history.$UID
    }

There's a whole bunch of other stuff that has to be thrown in to set up
the initial history when the shell first starts and to make sure you don't
try to write where you can't or read where there is no file; but you get
the idea.

A more complex solution would encode the path of any directory cd'd to as
a file name relative to a writable subdir of your home directory, so that
you are guaranteed to be able to write and to have control over what you
read.

} What do folks think about incorporating something along these lines in a
} future release?

I don't think it's easily enough generalized to be done as a builtin op.
Certainly a sample script to set it up would be interesting to include.

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern


      reply	other threads:[~1997-04-12 10:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-11 19:08 Matt Pharr
1997-04-12  3:50 ` Bart Schaefer [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=970411205018.ZM5596@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=mmp@graphics.stanford.edu \
    --cc=schaefer@nbn.com \
    --cc=zsh-users@math.gatech.edu \
    /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).