zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Peter Stephenson <pws@ifh.de>,
	zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: pushd
Date: Fri, 11 Oct 1996 12:53:54 -0700	[thread overview]
Message-ID: <961011125354.ZM10006@candle.brasslantern.com> (raw)
In-Reply-To: Peter Stephenson <pws@ifh.de> "pushd" (Oct 11,  2:34pm)

On Oct 11,  2:34pm, Peter Stephenson wrote:
} Subject: pushd
}
} I know I'm several months behind everyone else, but I've belatedly
} realised that I find the new pushd behaviour unusable

Nevertheless, tcsh and bash behave the same way ...

} bring an arbitrary directory (say via pushd +2) to the top there's no
} way of knowing where in the stack the directory you were just in has
} landed.

Sure there is.  For `pushd +N', you can always get the original stack
ordering back with `pushd -(N-1)'.  It annoys me a little bit that using
`pushd -0' changes directory whereas `pushd +0' does not -- that is, I
think the current directory should be position zero in either direction,
not just when counting from the left -- but once again that's the way
that bash does it (tcsh doesn't accept `-N' at all).

(The above assumes, of course, that PUSHD_MINUS isn't set.)

} If I use `cd +2' the last directory disappears altogether.

I've always wondered whether the benefits of connecting `cd' to the
directory stack are worth it.  However, this is what I'd call the
expected behavior; you didn't ask for the current directory to be
put on the stack.

} (to put it another way, the
} behaviour pushing an existing directory when PUSHD_IGNORE_DUPS is set
} is now incompatible with pushd +n).

Ah, now that *is* a problem, because PUSHD_IGNORE_DUPS chops entries out
of the middle of the stack.  In that case you really do lose track of
where you are and where you came from.

Is the following more like the behavior you want?

function pushd() {
    setopt localoptions
    case $1 in
    +*) setopt pushdignoredups
	builtin pushd ${${=$(dirs)}[$1]} ;;
    -*) setopt pushdignoredups
	builtin pushd ${${=$(dirs)}[$1-1]} ;;
    *) builtin pushd $* ;;
    esac
}

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern

New male in /home/schaefer:
>N  2 Justin William Schaefer  Sat May 11 03:43  53/4040  "Happy Birthday"


  parent reply	other threads:[~1996-10-11 20:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-10-11 12:34 pushd Peter Stephenson
1996-10-11 13:01 ` pushd Vinnie Shelton
1996-10-11 15:13   ` pushd Peter Whaite
1996-10-11 19:53 ` Bart Schaefer [this message]
1996-10-15 12:45   ` pushd Peter Stephenson
1996-10-15 17:08     ` pushd Bart Schaefer
1996-10-15 17:34       ` pushd Zoltan Hidvegi
1996-10-16  5:38         ` pushd Bart Schaefer
1996-10-16  8:42           ` pushd Zefram
1996-10-16 17:36             ` pushd Bart Schaefer
1996-10-16 18:10               ` pushd Zefram
1996-10-16 21:16                 ` pushd Bart Schaefer
1996-10-17 13:22                   ` pushd Anthony Heading
1996-10-17 13:47                     ` pushd Peter Stephenson
1996-10-17 17:01                     ` pushd Bart Schaefer
1996-10-16 22:28                 ` pushd Zoltan Hidvegi
1996-10-16 12:42           ` pushd Peter Stephenson
1996-10-15 18:45       ` pushd Anthony Heading
1996-10-18 13:14 pushd Ray Van Tassle-CRV004

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=961011125354.ZM10006@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=pws@ifh.de \
    --cc=schaefer@nbn.com \
    --cc=zsh-workers@math.gatech.edu \
    /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).