home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume6
/
mkalias
< prev
next >
Wrap
Internet Message Format
|
1989-02-03
|
3KB
Path: xanth!nic.MR.NET!csd4.milw.wisc.edu!leah!itsgw!steinmetz!uunet!allbery
From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
Newsgroups: comp.sources.misc
Subject: v06i020: csh alias generator
Message-ID: <47752@uunet.UU.NET>
Date: 29 Jan 89 21:00:08 GMT
Sender: allbery@uunet.UU.NET
Reply-To: Martin Ward <martin%EASBY.DURHAM.AC.UK@CUNYVM.CUNY.EDU>
Lines: 77
Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
X-Arch-Keywords: csh, sed, sh, alias, script, NOT-SHAR-ED
Posting-number: Volume 6, Issue 20
Submitted-by: Martin Ward <martin%EASBY.DURHAM.AC.UK@CUNYVM.CUNY.EDU>
Archive-name: mkalias
Well, here is is! Version 1.0 of "The Ultimate Alias Machine"(tm). Now you
too can create aliases as complicated as you like!! Impress your boss!!!
Confound your friends!!!! Mystify your mother!!!!!
What you need are the following files:
--------------- $HOME/bin/mkalias ------------------------------
#! /bin/sh
# mkalias - command to create alias commands in a file.
# prints the file name.
temp=/usr/tmp/$USER.alias$$
case $# in
0) sed -f $HOME/bin/lib/mkalias.sed >$temp
echo $temp ;;
*) echo 1>&2 "Usage:" `basename $0`
exit ;;
esac
------------------------------------------------------------------
--------------- $HOME/bin/lib/mkalias.sed-------------------------
# sed script to translate alias output into and alias command.
# replace ! by \!
# replace ' by '"'"'
# add alias to beginning
# add ' after first word
# add ' to end.
s/!/\\!/g
s/'/'"'"'/g
s/[ ]*[ ]*/& '/
# that's: s/[<space><tab>]*[<space><tab>]*/& '/
s//alias /
s/$/'/
------------------------------------------------------------------
--------------- $HOME/.aliases -----------------------------------
# extra aliases:
alias talias 'set aliasFile=`mkalias`; source $aliasFile; rm -f $aliasFile'
alias palias 'set aliasFile=`mkalias`; source $aliasFile; cat $aliasFile
>>^/.aliases; rm -f $aliasFile'
# aliases from alias generator:
------------------------------------------------------------------
Then add the line:
source ^/.aliases
to your .cshrc file, source .cshrc and away you go!
To use, type talias (for temporary aliases which only last as long as this
session) or palias (for permanent additions to the .aliases file), then
enter a list of aliases in the form of the _output_ of the alias command.
Type the EOF character to finish (usually D).
Eg if you want to create an alias foo where:
foo [files ...]
looks for all the lines in the files which contain * charaters you type:
palias
foo grep '*' !*
D
and you can start using foo straight away.
Have fun!
Martin. (martin@uk.ac.dur.easby)
My ARPANET address is: martin%EASBY.DUR.AC.UK@CUNYVM.CUNY.EDU
JANET: martin@uk.ac.dur.easby BITNET: martin%dur.easby@ac.uk
UUCP: ...!mcvax!ukc!easby!martin