* per-directory history?
@ 1997-04-11 19:08 Matt Pharr
1997-04-12 3:50 ` Bart Schaefer
0 siblings, 1 reply; 2+ messages in thread
From: Matt Pharr @ 1997-04-11 19:08 UTC (permalink / raw)
To: zsh-users
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. That is,
for some (or all) of the directories that I ever work in, it would be nice
to be able to segregate the command history based on the directory. Even
better would be able to group sets of directories and have a separate
history records for groups of directories.
Is this easily done at the user level given zsh's current set of features?
What do folks think about incorporating something along these lines in a
future release?
-matt
--
Matt Pharr
mmp@graphics.stanford.edu
<URL:http://www-graphics.stanford.edu/~mmp>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: per-directory history?
1997-04-11 19:08 per-directory history? Matt Pharr
@ 1997-04-12 3:50 ` Bart Schaefer
0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1997-04-12 3:50 UTC (permalink / raw)
To: Matt Pharr, zsh-users
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-04-12 10:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-11 19:08 per-directory history? Matt Pharr
1997-04-12 3:50 ` Bart Schaefer
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).