zsh-users
 help / color / mirror / code / Atom feed
* dirstack-inheritance
@ 1999-10-06  9:53 Johannes Mähner
  1999-10-06 18:09 ` dirstack-inheritance Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Mähner @ 1999-10-06  9:53 UTC (permalink / raw)
  To: ZSH User

Is there a way to inherit the directory stack in other zsh-sessions?
(analogous mechanism as of command-history (incappendhistory,
sharehistory) wanted)

Thanks in advance!


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: dirstack-inheritance
  1999-10-06  9:53 dirstack-inheritance Johannes Mähner
@ 1999-10-06 18:09 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 1999-10-06 18:09 UTC (permalink / raw)
  To: Johannes Mähner, ZSH User

On Oct 6, 11:53am, Johannes Mähner wrote:
} Subject: dirstack-inheritance
}
} Is there a way to inherit the directory stack in other zsh-sessions?
} (analogous mechanism as of command-history (incappendhistory,
} sharehistory) wanted)

You aren't actually suggesting that all the shells change current directory
in sync, are you?  I'm also uncertain what you think should happen in one
shell when another shell cycles its directory stack or swaps the top entry
with $PWD or the like.  The directory stack can change in a whole lot of
ways that history can't.  If one shell pops a directory out of the stack,
does it disappear from all the shells' stacks?  If not, and like history
you only share additions, when does the stack ever shrink?  (Arbitrarily
discard entries from the end when it exceeds a certain size?)

If you have 3.1.6-pws-6, you might be able to work something out using
`zmodload parameter' and then mucking with $dirstack.  If all you care
about is having a new shell start up with the same directory stack as the
most-recently-used shell, you can do put in .zshrc something like:

zmodload parameter && {
  [[ -f ~/.zdirs ]] && dirstack=( $(< ~/.zdirs) ) && popd
  precmd() {
    dirs >! ~/.zdirs
  }
}

(The "popd" is because "dirs" is equivalent to "echo $PWD $dirstack".)

If you don't have 3.1.6-pws-6, you can do

dirstack=( $(< ~/.zdirs) )
cd $dirstack[-1]
dirstack[-1,-1]=()
while (($#dirstack)); do
  pushd $dirstack[-1]
  dirstack[-1,-1]=()
done

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-10-06 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-10-06  9:53 dirstack-inheritance Johannes Mähner
1999-10-06 18:09 ` dirstack-inheritance 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).