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

Terminal 101 - Handy aliases UNIX
Warning - For new unix users only... this is intended for mac users new to unix who wish to make the terminal a bit more comfortable.

You can define any number of shortcuts (aliases) to start up applications. For example, to start up TextEdit from the command line and open a file, all you need to do is type:

te main.C &

where: te is the alias you specify, main.C is the name of the text file that you want to edit, and & backgrounds the process (which means you can continue working in the command line).

To learn how to set this up and add to your UNIX knowledge, read the rest of the article ... and thanks to 'anonymous' for sending this in!

To set this up, do the following:

1) Create the following directory: ~/Library/init/tcsh

ie in your home directory, go to the Library folder and create an "init" folder (if it's not there already), then create a "tcsh" folder inside the "init" folder.

2) Create a text file called "aliases.mine" inside the tcsh folder (if you do this using TextEdit, make sure you select "Make Plain Text..." option).

3) Add the following line to this file:

alias te '/Applications/'

Note, when generating alias names, make sure that a command doesn't exist first. Eg, I couldn't use the name "tee" because there is a program called that already (type "man tee" to find out more about it).

4) Save the file (path should read "~/Library/init/tcsh/aliases.mine").

5) Open a new Terminal window and type "alias". You should see your "te" entry in amongst other entries (they are essentially command-line shortcuts).

6) Try it out... simply type te

and that should start TextEdit. You'll notice that you cannot use your Terminal window until you quit TextEdit. To avoid that from happening, just type

te &

which will open TextEdit in the background (which means you can use the Terminal while TextEdit is running). To open a file as well, just type in the filename after "te" and before '&', like

te foo.txt &

If you want to get really tricky, you can open multiple files in one go! Navigate to a directory with mulitple files (lets say they are all rtf's and have the ".rtf" extensions) and enter:

te *rtf &

this will open TextEdit with a window for each file.

Getting Dirty! If you really want to be even more tricky, you will find the single character regex handy. Say you're a programmer (as we all are :) and you have the following files:


to open them in one go, just type:

te myApp.[Ch] & or te *.[Ch] &

to open all files that end with either a 'C' OR 'h'.

Note: Each time you issue a "te" command, this will open a new copy of TextEdit. Do this a few times without quitting TextEdit, and you'll find multiple copies open!

What else can I have in my aliases.mine file? Anything you want... here's an abridged version of my aliases.mine file (note, anything after the '#' character is ignored):
# Aliases file
# Wilfredo Sanchez Jr. |
# June 10, 1994
# MIT Project Athena
alias l 'ls -g --color'
alias lk 'ls -ga --color'
alias ll 'ls -lg --color'
alias llk 'ls -lag --color !* | more'
alias hack 'cd ~/documents/hack'
alias rascal 'telnet'
alias te '/Applications/'

  • Currently 1.75 / 5
  You rated: 1 / 5 (4 votes cast)

Terminal 101 - Handy aliases | 9 comments | Create New Account
Click here to return to the 'Terminal 101 - Handy aliases' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Wrong file name & location.
Authored by: Loren on Mar 30, '01 06:14:28PM

I followed your directions but had no luck. After getting a Unix guru friend on the phone we figured out that the file needs to be in the home directory, and named .tcshrc

At least, that is what worked for me.


[ Reply to This | # ]
Wrong file name & location.
Authored by: Anonymous on Mar 31, '01 02:53:22AM

Indeed you can create a file called ".tcshrc" in your home directory... but that is a very Unixy way. Reading the instructions from the Global alias file, the directory that I mentioned in the article is the preferred method (I guess they don't want you to litter your home directory with "." files?). Perhaps something that I didn't make clear in the article (read: I forgot to mention :-) is the meaning of the '~' in the path. It basically translates to you home folder, ie. the file path ends up as:


actually expands out to:


That definately works, my machine is configured to that exactly. Again either location and file name is correct and will get you aliases working. Hope you are enjoying the shortcuts :)

Sorry for the confusion


[ Reply to This | # ]
Wrong file name & location.
Authored by: iMike on Mar 31, '01 07:40:07AM
Both methods will work (as Dave mentioned). However, the more correct and
less tainted method for creating aliases is to create the "aliases.mine" file
inside ~/Library/init/tcsh/ (as mentioned by Dave).

Just thought I would reiterate that info. Loren, use this method for aliases and
use your .tcshrc file for changing your prompt. You can also add .login and
.logout files to your home directory to change your shell login and logout info. 8^)


[ Reply to This | # ]
Wrong file name & location.
Authored by: Anonymous on Mar 31, '01 08:19:07PM

Actually, you can do it all in the ~/Library/init/tcsh directory. You can set up your login, logout, tcsh defaults, environment, etc. For more info, read the README file in:


Hope this helps


[ Reply to This | # ]
Wrong file name & location.
Authored by: iMike on Apr 12, '01 04:29:56AM

Maybe I wasn't clear or you misunderstood, but ~/Library/init/tcsh/ is exactly
where I was saying to setup the .tcshrc, .login, .logout, aliases.mine,
completions.mine, rc.mine, and environment.mine files.

Just to should create and edit the .tcshrc, .login, .logout, aliases.mine,
completions.mine, rc.mine, and environment.mine files in ~/Library/init/tcsh/.


[ Reply to This | # ]
Wrong way...
Authored by: Bart VdBroeck on May 16, '01 05:11:21AM

Regardless of where you put this stuff
(I happen to like ".whatever" files in the root of my home directory. They don't bother me when I get a listing of it (don't use the -a option normally), and when I feel like editing one of them, I just have to type something like "cd;pico .cshrc", not "pico ~/Library/init/tcsh/aliases.mine". How does one type a "~" on an azerty-keyboard in tcsh anyway?)
you should put the right stuff in it... First of all, I guess you could change the alias to

"/Applications/ !* &"

to save you from having to type the ampersand (&) everytime. But that still isn't the right way. This is not your daddy's *nix people! These bundles have a reason of existence. You're not supposed to navigate into them frequently. Almost never actually, except if you want to hack them in some way. So the Mac OS X way to do it would be:

alias te "open -a"

Isn't that a lot more elegant? This won't start a new TextEdit everytime you use it and the shell isn't locked up after issuing it. Two behaviors which show you this is the Mac way to do it. And whenever Apple decides bundles should have separate optimized binaries for G4 and G5 processors (just freewheeling here), this will still work.

[ Reply to This | # ]
Wrong way...
Authored by: Bart VdBroeck on May 16, '01 06:20:23AM

OK, here's the problem with this comment feature again. You have to put a backslash (the flipped version of "/") right before "!*"

[ Reply to This | # ]
alias te
Authored by: Garrett on May 22, '01 12:56:28AM

I liked your idea and did it. Problem is that te doesn't appear as an alias when I type in "alias". Thus when I type te, the terminal wants to send me to tee and says te does not exist. I thought perhaps TextEdit was on rich even if it said it wasn't and tried it again using code warrior text. Same result.

I am a learner here so I put the file "aliases.mine" in the folder using regular file techniques rather than from the terminal. Path = Users/me/Library/init/tcsh/aliases.mine which must be ~/Library/init/tcsh/aliases.mine

Do you suppose I should try the other "unixy" place to file this?


[ Reply to This | # ]
Alias.mine problems
Authored by: cedmond on Apr 07, '02 12:04:30PM

For folks having trouble with this I did.
Creating a file titled "aliases.mine" in the directory "~/Library/init/tcsh/" does work, but with the following requirements.

Make sure the last line of your text file has a carriage return. In other words, go to the end of the very last line of your document and hit "return". There has to be an empty line at the end of the file or it won't work.

Make sure the file is plain text and that there is no hidden extension. Likewise, be sure that the extension ".mine" is visible. To check this select the "aliases.mine" file in the Finder and do "Get Info". Go to "Name & Extension", uncheck "Hide Extension" if checked and check to be sure the name is "aliases.mine" exactly.

Hope this helps.

[ Reply to This | # ]