Mac Terminal Shortcuts For Repetitive Commands

April 29, 2012   

If you've always wondered if it would be cool to be able to type your own custom command into mac terminal and have it do whatever wonderful command thing, you can conjure up in your wonderfully creative head.

Then i'm afraid to say it's just not possible...ha...only kidding...keep reading if you want to find out how, it's actually really quite simple.

So to setup these ultra cool, simple shortcut commands for your mac terminal you need to locate or create a .profile file.

If you have one already you'll be able to find it using the following commands.

cd ~/
ls -f

This either will or won't reveal a .profile file. If it doesn't, no sweat, we'll just go ahead and create it.

mate ~/.profile

(note i'm using Textmate here, you could use vim / nano or whatever gui takes your fancy.)

Once you've got this file open we're going to use alias to define our shortcuts.

Here's an example.

alias davetest="cd /Applications/MAMP/htdocs/davetestsite/"

Save the file, relaunch terminal and type "davetest" or whatever your shortcut is and wollah you'll have created your very own customised mac terminal shortcut command.

Good work.


blog comments powered by Disqus