[comp.sources.d] idea for tcsh

edward@csvaxa.UUCP (12/04/87)

I'm really impressed  with the latest  version of tcsh,  with spelling
checking, emacs-style editing, etc. However, I've often wanted to save
my  directory stack between  sessions,   as  currently  done with  the
history list. Has anyone made any hacks to allow this? We haven't  got
access  to csh sources so  I can't have a crack  myself. Presumably it
wouldn't be too big a job.

  Ed Wilkinson   ...!uunet!vuwcomp!edward  or  edward@comp.vuw.ac.nz
-- 
  Ed Wilkinson   ...!uunet!vuwcomp!edward  or  edward@comp.vuw.ac.nz

gwyn@brl-smoke.ARPA (Doug Gwyn ) (12/05/87)

In article <147@csvaxa.UUCP> edward@csvaxa.UUCP (Edward Wilkinson) writes:
>I'm really impressed  with the latest  version of tcsh,  with spelling
>checking, emacs-style editing, etc. However, I've often wanted to save
>my  directory stack between  sessions,   as  currently  done with  the
>history list. Has anyone made any hacks to allow this?

I haven't been keeping track of tcsh, but unless it's really bogus
you shouldn't have any trouble doing what you ask in user mode,
without having to hack on the shell itself.  The way I would do this
would be to make my .logout file create a "dot file" in my home
directory containing the directory stack (which at least in my
Bourne shell environment is just the value of an environment
variable kept up to date by "cd", "pushd", etc.).  Then my .profile
(or perhaps my .shrc per-shell startup file) would, if this dot file
were present, use it to initialize the environment variable.

I leave the details as an exercise for the poor tcsh user.

sa@ttidca.TTI.COM (Steve Alter) (12/07/87)

In article <6797@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) writes:
>In article <147@csvaxa.UUCP> edward@csvaxa.UUCP (Edward Wilkinson) writes:
>>                               ... [In tcsh] I've often wanted to save
>>my  directory stack between  sessions,   as  currently  done with  the
>>history list. Has anyone made any hacks to allow this?
>
>                                        ...  The way I would do this
>would be to make my .logout file create a "dot file" in my home
>directory containing the directory stack (which at least in my
>Bourne shell environment is just the value of an environment
>variable kept up to date by "cd", "pushd", etc.).  Then my .profile
>(or perhaps my .shrc per-shell startup file) would, if this dot file
>were present, use it to initialize the environment variable.

How about this:
In .logout:
	dirs > ~/.stack

In .login:
	if ( -r ~/.stack ) then
		foreach d ( `cat ~/.stack` )
			pushd $d > /dev/null
			pushd +1 > /dev/null
		end
		popd > /dev/null
	endif
	echo -n "Directories: " ; dirs

It works; I just finished testing it.  Note that this is NOT specific
to tcsh; it should work in almost any implementation of the c-shell
because this is all standard stuff.

-- Steve Alter
...!{csun,rdlvax,trwrb,psivax}!ttidca!alter  or  alter@tti.com
Citicorp/TTI, Santa Monica CA  (213) 452-9191 x2541

ejp@ausmelb.oz.au (Esmond Pitt) (12/09/87)

In article <147@csvaxa.UUCP> edward@csvaxa.UUCP (Edward Wilkinson) writes:
> I've often wanted to save
> my  directory stack between  sessions,   as  currently  done with  the
> history list. Has anyone made any hacks to allow this?

You can do this outside, from .login and .logout. Regardez:

.logout:

# save dir stack - if we can!
if ( -w $HOME ) then
    dirs > $HOME/.dirs
endif

.login:

# get dirs
foreach d (`cat ${HOME}/.dirs`)
    pushd $d >& /dev/null
    pushd +1 >& /dev/null	# swap to bottom of stack
    end
unset d				# Clean, ain't I?
popd				# pop ~ to get to last wd, and display stack
set argv=(`dirs`)		# store dir stack, to access as $[0-9]

-- 
Esmond Pitt, Austec International Ltd
...!seismo!munnari!ausmelb!ejp,ejp@ausmelb.oz.au