Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Changing global aliases' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Changing global aliases
Authored by: tapella on Feb 02, '01 08:28:46PM

If you want to change the "built-in" aliases or add aliases that every user gets automatically, you edit a different file:

This assumes that you're using tcsh as your shell, of course. tcsh is the default Terminal shell in OS X, so you can just edit the above file with the default install.

PS I'm partial to ls -alF myself :-)

[ Reply to This | # ]
Authored by: robh on Feb 05, '01 09:19:26AM

Another handy trick with aliases is to use !* to embed arguments inside an alias, e.g.

alias zlines 'zcat !* | wc -l'

So that the command "zlines myfile.gz" is expanded into "zcat myfile.gz | wc -l", i.e. a tool to count lines in a gz-compressed file.

Also useful for users of aliases is 'which'. This command will show you either where the command is located or what it is an alias for, e.g.

which zcat

which zlines
zlines: aliased to zcat !* | wc -l

If you find aliases useful for creating shorter more memorable commands, another tip I'd give is to set up environment variables in your .tcshrc (or .cshrc) file, e.g.

setenv LOGS /Library/WebServer/Logs/
setenv WEBLOG /Library/WebServer/Logs/apache_access_log
setenv ERRLOG /Library/WebServer/Logs/apache_error_log

Then you don't need to remember where your webserver access log is (handy if you work with multiple machines where the location can vary), you can then do thing like this..

cd $LOGS
tail -f $WEBLOG

Note that "tcsh" will autocomplete environment variables when you hit the TAB key, e.g. if you typed "wc $WE" then hit TAB, tcsh will fill in the rest to make it "wc $WEBLOG".

[ Reply to This | # ]