zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: "Johannes Mähner" <johanm@camline.com>,
	"ZSH User" <zsh-users@sunsite.auc.dk>
Subject: Re: dirstack-inheritance
Date: Wed, 6 Oct 1999 18:09:09 +0000	[thread overview]
Message-ID: <991006180909.ZM10734@candle.brasslantern.com> (raw)
In-Reply-To: =?iso-8859-1?Q?=3C37FB1C0E=2E4E5E623D=40camline=2Ecom=3E?= =?iso-8859-1?Q?Comments=3A_In_reply_to__Johannes_M=E4hner_=3Cjohanm=40cam?= =?iso-8859-1?Q?line=2Ecom=3E?= =?iso-8859-1?Q?________=22dirstack-inheritance=22_=28Oct__6=2C_11=3A53am?= =?iso-8859-1?Q?=29?=

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


      reply	other threads:[~1999-10-06 18:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-06  9:53 dirstack-inheritance Johannes Mähner
1999-10-06 18:09 ` 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=991006180909.ZM10734@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=johanm@camline.com \
    --cc=zsh-users@sunsite.auc.dk \
    /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).