From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28537 invoked from network); 12 Apr 1997 10:54:09 -0000 Received: from euclid.skiles.gatech.edu (root@130.207.146.50) by ns1.primenet.com.au with SMTP; 12 Apr 1997 10:54:09 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id XAA08082; Fri, 11 Apr 1997 23:49:25 -0400 (EDT) Resent-Date: Fri, 11 Apr 1997 23:41:42 -0400 (EDT) From: "Bart Schaefer" Message-Id: <970411205018.ZM5596@candle.brasslantern.com> Date: Fri, 11 Apr 1997 20:50:18 -0700 In-Reply-To: Matt Pharr "per-directory history?" (Apr 11, 12:08pm) References: Reply-To: schaefer@nbn.com X-Mailer: Z-Mail (4.0b.820 20aug96) To: Matt Pharr , zsh-users@math.gatech.edu Subject: Re: per-directory history? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"X1Myf1.0.mx1.rHmJp"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/799 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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