[Home] [Blogs] [XiTouch] [EMILY] [Tools] [Services] [Teach] [Mac] [My Blog] [Contact]

Setting up aliases.mine in OSX

Note: - Apple changed the default shell from tcsh to bash when 10.3 was released. This script is for the tcsh shell. To enter a tcsh shell from a bash shell, type tcsh at the command line prompt. If this is greek to you, you're not ready for the info on this page.

You're beginning to tinker around with the Unix command line in OSX, and you're now at the point where you are feeling frustrated with what seems like repetitive typing of the same commands and parameters again and again (and you have already uncovered the handy up-arrow and tab-complete features). You are now ready to learn more about configuring your shell environment.

As background, if you enter this into your command line shell (yes, this is insecure pseudocode!):
alias ssh1 'ssh myserver.mydomain.com -l myshortname -p mypassword'
you will find that you can connect to myserver.mydomain.com by entering only ssh1. What a handy time saver! Unfortunately, when you exit your shell, you lose this shortcut. But there is a solution!

The file aliases.mine can hold an arbitrary number of such aliases, which are automatically enabled at login time. However, setting it up is a bit tedious; the following Applescript does the work for you, and provides a tidy teaching lesson as well.
This version is long in the tooth. I suggest the power user version below if you are using Tiger or later.
The version below is for power users and my own convenience. Here are the features it adds:
  • more aliases placed into aliases.mine
  • sets pico as the default crontab text editor
  • works for crazy people who operate in the GUI as root
  • password entry is more secure
To set up aliases.mine, copy and paste the above script into your Applescript Script Editor, compile it, and run it. The script includes several display dialog commands, which allow you to watch, learn, and debug, and to stop the script if something seems awry. It is also helpful to open the Script Editor event log (before running the script!) and check "Show Event Results" to follow the progress of the script.

When completed, a Finder alias to aliases.mine will be in your Favorites folder (along with a Finder alias to ~/Library/init/tcsh/), and it should (hopefully) conveniently open in BBEdit TextWrangler get TextWrangler. If you have trouble after editing any of the files using TextWrangler, be sure to save them using Unix line breaks (there's an "Options" button in the open/save dialog). You can also edit your aliases.mine file by typing myaliases at your command line prompt. You will need to exit your current shell and log in anew before these changes will take effect.

The inspiration for this script can be viewed in the terminal with:
cat /usr/share/tcsh/examples/README
which will bring up the following:
The above Applescript creates, but does not further modify, completions.mine, rc.mine, and path. This is because this is a work in progress, I have no current need to extend those functions further, and I wanted to keep the script lean and focused on aliases.mine (and I don't know yet what I can do with them anyway).


My thanks to
Daniel Woods who helped me debug the problem with /usr/share/tcsh/examples/aliases.

[Home] [Blogs] [XiTouch] [EMILY] [Tools] [Services] [Teach] [Mac] [My Blog] [Contact]

©1997-2010 Jeffrey W Baumann & LinkedResources, Inc. All Rights Reserved. Last Updated January 22, 2011.