Printing Working Directory in CSH (or SH for that matter)

Joseph Allen jallen at eeserv1.ic.sunysb.edu
Sun May 5 05:48:39 AEST 1991


In article <1991May1.001454.9035 at nshore.ncoast.org> steve at nshore.ncoast.org (Stephen J. Walick) writes:
>As quoted from <112 at comix.UUCP> by jeffl at comix.UUCP (Jeff Liebermann):
>[how do you make 'sh' show current path whenever you "cd"]

All you have to do is replace all occurances of 'cd' in the shell program
with some new name.  I used my editor to do this, but most editors can't
handle ascii files so I made a simple program to do it.  The new name for the
command I picked is 'ce'.  Originally I tried 'Cd' but that didn't work.  I
think either it doesn't like the command being in uppercase, or the commands
are sorted.  'ce' is in the same sort position as 'cd' and it works.

1) compile this program to 'a.out'

	main()
	{
	int c;
	while(-1!=(c=getchar()))
	 if(c!='c') putchar(c);
	 else
	  {
	  c=getchar();
	  if(c=='d') putchar('c'), putchar('e');
	  else putchar('c'), putchar(c);
	  }
	}

2) Now run the program and make a new shell (it would not be a good idea to
   replace sh)

	cat /bin/sh | a.out >/bin/jsh
	chmod a+x /bin/jsh

   (jsh for Joe's shell, of course :-)

3) now change your shell to the new shell in the password file and put this
   in your .profile

	cd () { ce $*; PS1=`pwd`">"; }
	cd
-- 
/*  jallen at ic.sunysb.edu  */     /* Amazing */     /* Joe Allen 129.49.12.74 */
int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}



More information about the Comp.unix.xenix.sco mailing list