home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume6 / mkalias < prev    next >
Internet Message Format  |  1989-02-03  |  3KB

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