Path: utzoo!attcan!uunet!mcsun!sunic!his!jonas From: jonas@his.UUCP (Jonas Mellin) Newsgroups: comp.unix.questions Subject: Re: Macro facility in csh? Message-ID: <290@his.UUCP> Date: 4 Sep 89 06:09:54 GMT References: <8998@zodiac.ADS.COM> Reply-To: jonas@his.UUCP (Jonas Mellin) Organization: Hogskolan i Skovde, Skovde, Sweden Lines: 53 In article <8998@zodiac.ADS.COM> charleen@ADS.COM () writes: >I may be asking for too much, but I write a lot of csh scripts and >it sure would be handy to have macro capability. I don't find any >mention of it in the documentation, though. > >Responses on the order of "Well, shoot, if you want that much >flexibility you should be using ______" welcome as well. > >Charleen It is possible to use aliases for the purpose. alias cd 'set old=$cwd; chdir \!*; pwd' alias back 'set back=$old; cd $back; unset back' Here is an example using it: ...> cd /tmp /tmp ...> back (whereever you were before) ...> or set pdl= alias pd 'chdir \!:1;set pdl=($pdl $cwd); pwd' alias ccd 'echo $pdl; echo -n index: ; set pdi=$<; chdir $pdl[$pdi]; pwd' alias cdn 'chdir $pdl[\!:1]; pwd' alias ud 'echo $pdl; echo -n index:; set pdi=$<; @ pdii=$pdi + 1;'\ '@ pdi=$pdi - 1; set pdl=($pdl[-$pdi] $pdl[$pdii-]);'\ 'echo $pdl; unset pdi pdii' alias pdreset set pdl= where pd registers a directory in the pdl ccd displays pdl first and prompts the user for an index. If an correct index is used it changes to the directory cdn change to the nth directory in the indexlist. ud removes a directory from pdl pdreset resets pdl to an empty list Both of these examples are from the book 'An Introduction To Berkeley UNIX'. I am more inclined to use Bourne Shell for shellscript programming. _____________________________________________ / / / / /\ / / /| /| |E-mail: jonas@his.se / /--/ / \ / / / |/ | |UUCP: ...!sunic!his!jonas / / / / \/ / / / / | |Phone: +46 500 77646 /______________________/ \_/ onas / |ellin|Fax: +46 500 16325 Snailmail: Jonas Mellin,Hogskolan i Skovde, Box 408, 541 28 Skovde, Sweden