A script to create aliases

Jul 26, '02 09:26:03AM

Contributed by: Anonymous

I'm not sure if this is useful for some, but I use this shell script I wrote for creating and adding aliases to my .cshrc file all the time. I must have 2 or 3 dozen aliases in .cshrc file. Here's the shell script:

#!/bin/sh

echo -n "Enter the CMD you want to make an alias for: " ; read CMD ;
echo -n "Enter the alias without quotes: " ; read ALIAS ;

echo "alias" $CMD "'"$ALIAS"'" >> /Users/$USER/.cshrc

echo " "
tail -1 /Users/$USER/.cshrc

echo " "
echo "You need to relogin now!"
su -l $USER
Save this somewhere in your path, make it excecutable (chmod 755 script_name) and then type 'rehash' to activate it. Now simply type the name of the script when you wish to create a new alias.

[Editor's note: If you use the OS X convention of an "aliases.mine" file in ~/Library/init/tcsh, simply replace ".cshrc" with that path and filename on the two lines where it appears.]

Comments (9)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020726092603502