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


Click here to return to the 'set up an alias' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
set up an alias
Authored by: jmil on May 01, '01 09:57:54PM

you can write an alias so all you have to do is type a string like "connect", or anything you really want, and it will run any command of your choice. You will have to edit /private/etc/csh.cshrc as root. To avoid using emacs, vi, or anything else that is hard to understand, just type the following:
su
(enter your administration password here)

open -a /Applications/TextEdit.app/ /private/etc/csh.cshrc
(this tells the terminal to open csh.cshrc with TextEdit.app)

you should see a line that says "source /usr/share/init/tcsh/rc"
all you have to do is think of an alias, and type it in. Here is an example:

alias myfavorite "open /Users/myusername/Library/Terminal/mycustomterminal.term"

this creates the alias "myfavorite" such that when you type "myfavorite" in a terminal window, the terminal will execute the command in quotes and will thus open mycustomterminal.term. You won't have to type "open /Users/myusername/...." ever again!

edit until you're happy with your aliases. You could also add another command to this file such as:

alias myaliases "open -a /Applications/TextEdit.app/ /private/etc/csh.cshrc"
This will allow you to simply type su to become superuser, and then "myaliases" to open your csh.cshrc file in TextEdit.app.

Now File>Save

Now all you have to do is tell the terminal to recognize your new commands. you could restart the terminal, or simply type

source /private/etc/csh.cshrc

this will execute the csh.cshrc file, and the terminal will recognize your new aliases as commands. Now just type "myfavorite" anytime you want to execute that command.
If it doesn't work for some reason, just type "source /private/etc/csh.cshrc" again, or check that your syntax in csh.cshrc is correct.

Using aliases can make your work in the terminal extremely efficient, but also dangerous if you don't know what you're doing. I WOULDN'T recommend trying to combine "sudo" with any aliases you try to create. I hope this is clear. Let me know if it isn't, or if you need more help. Good Luck.

jmil



[ Reply to This | # ]