home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume06 / mkalias < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  2.8 KB

  1. From decwrl!wyse!uunet!allbery Sun Jan 29 20:29:52 PST 1989
  2. Article 793 of comp.sources.misc:
  3. Path: granite!decwrl!wyse!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v06i020: csh alias generator
  7. Message-ID: <47752@uunet.UU.NET>
  8. Date: 29 Jan 89 21:00:08 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: Martin Ward <martin%EASBY.DURHAM.AC.UK@CUNYVM.CUNY.EDU>
  11. Lines: 77
  12. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  13. X-Arch-Keywords: csh, sed, sh, alias, script, NOT-SHAR-ED
  14.  
  15. Posting-number: Volume 6, Issue 20
  16. Submitted-by: Martin Ward <martin%EASBY.DURHAM.AC.UK@CUNYVM.CUNY.EDU>
  17. Archive-name: mkalias
  18.  
  19. Well, here is is! Version 1.0 of "The Ultimate Alias Machine"(tm). Now you
  20. too can create aliases as complicated as you like!! Impress your boss!!!
  21. Confound your friends!!!! Mystify your mother!!!!!
  22.  
  23. What you need are the following files:
  24.  
  25. --------------- $HOME/bin/mkalias ------------------------------
  26. #! /bin/sh
  27. # mkalias - command to create alias commands in a file.
  28. # prints the file name.
  29. temp=/usr/tmp/$USER.alias$$
  30. case $# in
  31. 0) sed -f $HOME/bin/lib/mkalias.sed >$temp
  32.    echo $temp ;;
  33. *) echo 1>&2 "Usage:" `basename $0`
  34.    exit ;;
  35. esac
  36.  
  37. ------------------------------------------------------------------
  38.  
  39. --------------- $HOME/bin/lib/mkalias.sed-------------------------
  40. # sed script to translate alias output into and alias command.
  41. # replace ! by \!
  42. # replace ' by '"'"'
  43. # add alias to beginning
  44. # add ' after first word
  45. # add ' to end.
  46. s/!/\\!/g
  47. s/'/'"'"'/g
  48. s/[   ]*[     ]*/& '/
  49. # that's: s/[<space><tab>]*[<space><tab>]*/& '/
  50. s//alias /
  51. s/$/'/
  52.  
  53. ------------------------------------------------------------------
  54.  
  55. --------------- $HOME/.aliases -----------------------------------
  56. # extra aliases:
  57. alias talias 'set aliasFile=`mkalias`; source $aliasFile; rm -f $aliasFile'
  58. alias palias 'set aliasFile=`mkalias`; source $aliasFile; cat $aliasFile
  59.  >>^/.aliases; rm -f $aliasFile'
  60. # aliases from alias generator:
  61.  
  62. ------------------------------------------------------------------
  63.  
  64. Then add the line:
  65. source ^/.aliases
  66.  
  67. to your .cshrc file, source .cshrc and away you go!
  68.  
  69. To use, type talias (for temporary aliases which only last as long as this
  70. session) or palias (for permanent additions to the .aliases file), then
  71. enter a list of aliases in the form of the _output_ of the alias command.
  72. Type the EOF character to finish (usually D).
  73.  
  74. Eg if you want to create an alias foo where:
  75. foo [files ...]
  76. looks for all the lines in the files which contain * charaters you type:
  77.  
  78. palias
  79. foo grep '*' !*
  80. D
  81.  
  82. and you can start using foo straight away.
  83.  
  84.  
  85. Have fun!
  86.  
  87.                 Martin. (martin@uk.ac.dur.easby)
  88.  
  89. My ARPANET address is:  martin%EASBY.DUR.AC.UK@CUNYVM.CUNY.EDU
  90. JANET: martin@uk.ac.dur.easby    BITNET: martin%dur.easby@ac.uk
  91. UUCP:  ...!mcvax!ukc!easby!martin
  92.  
  93.  
  94.