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

Re: How to use popd?



On Wed, 19 Dec 2007 00:13:13 +0000 (UTC)
Jörg Sommer <joerg@xxxxxxxxxxxx> wrote:
> I've this situation:
> % dirs
> /usr ~ /tmp ~/Tmp/kernel/linux ~
> % pwd
> /usr
> 
> Now I want to go to /tmp. I thought popd +2 is what I need, but I'm still
> in /usr.

This is documented in the manual.  "popd +2" pulls the second item after
the head from the stack then changes to the new top.  The new top is still
/usr.

If you are trying to remove /usr and ~ from the stack completely
use "repeat 2 popd".  If you do this a lot, try

  rpopd() { repeat $1 popd; }

If you're just trying to bring /tmp to the head you need "pushd +2".

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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