Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: persistant Directory history?



On Mon, Nov 06, 2006 at 04:19:27PM -0800, William Scott wrote:
> 
> >the completion system, all you need to do is type:
> >
> >cd +<Tab>
> >
> >and cycle through your past directories (you may need to set the
> >auto_pushd option as well).
> >
> >See the "dirs" command, the auto_pushd option, the dirstack
> >array, the pushd/popd commands in zsh manual.
> 
> 
> Sorry to hijack, but is there a simple way to have a shared directory 
> stack between several terminal sessions?  I hacked together something that 
> works, but I have a bad feeling that I reinvented the wheel (and never 
> quite made it round).
[...]

Maybe something like:

SAVED_DIRSTACK=~/.zsh-dir-stack-shared
get_saved_dirstack() {
  [[ -r $SAVED_DIRSTACK ]] &&
    . $SAVED_DIRSTACK
}
save_dirstack() {
  print -r "dirstack=(${(@qq)dirstack})" > $SAVED_DIRSTACK
}

functions[preexec]+='
  get_saved_dirstack'
functions[chpwd]+='
  save_dirstack'

(untested).

-- 
Stéphane



Messages sorted by: Reverse Date, Date, Thread, Author