[net.sources] Csh quickie

ken@rochester.UUCP (02/11/86)

References:
Keywords:

This alias swaps the top two directories on the stack - useful for
directory hoppers like me:

alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
Snail: Comp. of Disp. Sci., U. of Roch., NY 14627. Voice: Ken!

avinash@ubvax.UUCP (Avinash Marathe) (02/11/86)

In article <15217@rochester.UUCP> ken@rochester.UUCP (Ipse dixit) writes:
>
>This alias swaps the top two directories on the stack - useful for
>directory hoppers like me:
>
>alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'
>
>	Ken
>-- 
>UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
>Snail: Comp. of Disp. Sci., U. of Roch., NY 14627. Voice: Ken!


You can accomplish this by just saying "pushd" without arguments.

Avinash Marathe
{ihnp4,allegra,decwrl}!amd!ubvax!avinash

ken@rochester.UUCP (Ipse dixit) (02/11/86)

In article <15217@rochester.UUCP> I wrote:
>alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'

Forget it. pushd with no args does the same thing. That will teach me
to RTFM.

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
Snail: Comp. of Disp. Sci., U. of Roch., NY 14627. Voice: Ken!

ken@turtlevax.UUCP (Ken Turkowski) (02/12/86)

In article <15217@rochester.UUCP> ken@rochester.UUCP (Ipse dixit) writes:
>This alias swaps the top two directories on the stack - useful for
>directory hoppers like me:
>
>alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'

I've got an ever faster one, which doesn't require an alias:

	pushd

with no arguments will swap the top two directories.  You can even do

	pushd +2

to swap (sort of) the top and second to the top.
-- 
Ken Turkowski @ CIMLINC, Menlo Park, CA
UUCP: {amd,decwrl,hplabs,seismo,spar}!turtlevax!ken
ARPA: turtlevax!ken@DECWRL.DEC.COM

flackc@stolaf.UUCP (Chap Flack) (02/12/86)

> This alias swaps the top two directories on the stack - useful for
> directory hoppers like me:
> 
> alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'

So does the following csh built-in command:

pushd


-- 
---------------------
Chap Flack				ihnp4!stolaf!agnes!flackc
Carleton College			ihnp4!stolaf!flackc
Northfield, MN  55057

akhanna@bbncc5.UUCP (Atul C Khanna) (02/12/86)

In article <15217@rochester.UUCP> ken@rochester.UUCP (Ipse dixit) writes:
>This alias swaps the top two directories on the stack - useful for
>directory hoppers like me:
>
>alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'
>

Typing "pushd" without any argument does the same thing, at least with
our csh.

-- 
Atul C Khanna
BBN Communications Corporation, Cambridge MA

miller@nlm-mcs.ARPA (Nancy Miller) (02/14/86)

> This alias swaps the top two directories on the stack - useful for
> directory hoppers like me:
> 
> alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'
> 
> 	Ken
> -- 
> UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
> Snail: Comp. of Disp. Sci., U. of Roch., NY 14627. Voice: Ken!

The same effect is achieved by typing
pushd
with no arguments!
-- 
________________________________________________________________________________

 __ __
 <> <>
   |  
  `-'
Nancy Miller
(miller@nlm-mcs.arpa)

gilbert@aimmi.UUCP (02/14/86)

In article <15217@rochester.UUCP> ken@rochester.UUCP (Ipse dixit) writes:
>
>This alias swaps the top two directories on the stack - useful for
>directory hoppers like me:
>
>alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'

Doesn't pushd on its own do this? 
-- 
	Gilbert Cockton, Alvey MMI Unit, Scotland 
USENET: ..(EUROPE)mcvax!ukc!cstvax!hwcs!aimmi!gilbert. JANET:gilbert@uk.ac.hw.cs(aimmi not NRS registered yet). ARPA:gilbert%cs.hw.ac.uk@cs.ucl.ac.uk (ditto)

sean@ukma.UUCP (Sean Casey) (02/14/86)

In article <437@ubvax.UUCP> avinash@ubvax.UUCP (Avinash Marathe) writes:
>In article <15217@rochester.UUCP> ken@rochester.UUCP (Ipse dixit) writes:
>>
>>This alias swaps the top two directories on the stack - useful for
>>directory hoppers like me:
>>
>>alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'
>
>You can accomplish this by just saying "pushd" without arguments.

A nice alias I use is:

alias	rot	pushd +1

The effect is to rotate all your pushdir'd directories one position
to the left.  I use this alias a lot.

Sean

dsmith@hplabsc.UUCP (David Smith) (02/14/86)

> This alias swaps the top two directories on the stack - useful for
> directory hoppers like me:
> 
> alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'
> 

So how is this any better than a pushd without arguments?

		David Smith
		HP Labs

chen@uiucdcsb.CS.UIUC.EDU (02/15/86)

/* Written  3:10 pm  Feb 10, 1986 by ken@rochester.UUCP in uiucdcsb:net.sources */
/* ---------- "Csh quickie" ---------- */
References:
Keywords:

This alias swaps the top two directories on the stack - useful for
directory hoppers like me:

alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'

	Ken
-- 
UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
Snail: Comp. of Disp. Sci., U. of Roch., NY 14627. Voice: Ken!
/* End of text from uiucdcsb:net.sources */

turner@imagen.UUCP (D'arc Angel) (02/19/86)

> This alias swaps the top two directories on the stack - useful for
> directory hoppers like me:
> 
> alias / 'set dirstack=`dirs -l`; popd; cd $dirstack[1]; pushd $dirstack[2]'
> 
> 	Ken
> -- 
> UUCP: ..!{allegra,decvax,seismo}!rochester!ken ARPA: ken@rochester.arpa
> Snail: Comp. of Disp. Sci., U. of Roch., NY 14627. Voice: Ken!

*** REPLACE THIS LINE WITH YOUR MESSAGE ***

under 4.2bsd so does:

pushd

-- 
----
	The master is not yet married, nor do I think he ever will be. 
			 -Rocky Horror Picture Show

Name:	James Turner
Mail:	Imagen Corp. 2650 San Tomas Expressway, P.O. Box 58101
        Santa Clara, CA 95052-8101
AT&T:	(408) 986-9400
UUCP:	...{decvax,ucbvax}!decwrl!imagen!turner
CompuServe: 76327,1575