Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What I'd like to be able to do is when I'm in Terminal is to type:

cd myFolderShortcut

And for it to go straight to a directory I have a set up with this alias. Is this possible?

I did do a google for it and Aliases may be what I want, but I couldn't get it to work.

share|improve this question
If what you want is a shorter command for cd'ing into a specific directory, all you need to do is add the following to your ~/.bashrc: alias myalias='cd /path/to/directory'. You can replace myalias with any custom command name you wish. – user111228 Jan 5 '12 at 20:13
Check out, it might also work for you. – Daniel Beck Jan 5 '12 at 20:18
up vote 16 down vote accepted

You don't need a shortcut file or anything like that.

You can set up an alias in ~/.bash_profile by adding the following line, so you just need to type myFolderShortcut to go there (without cd):

alias myFolderShortcut='cd /Users/danielbeck/Documents'

You also need to type the above command or

source ~/.bash_profile

to get this to take effect.  This works from any directory, but requires that your login shell be bash (which is OS X's default)

You can, of course, create symbolic links to other directories in your home directory. Then, when you open Terminal and are in your home directory, cding takes you to the linked directory.

ln -s /Users/danielbeck/Documents/Projects myProjectsDir

Then, type cd myProjectsDir and you're there (the displayed path contains myProjectsDir though, not Documents/Projects).

The symbolic link will show in Finder. To hide it, type chflags hidden myProjectsDir.

This will work only when you're in your home directory to start with (cd without arguments takes you there quickly; you can type both commands on the same line: cd && cd myProjectsDir).

share|improve this answer
cd as cd ~ is my favorite alias. – Rob Jan 5 '12 at 20:29
@Rob It's not technically an alias. cd without argument just implies ~. I like cd - better, by the way. – Daniel Beck Jan 5 '12 at 20:36
Hi, I could not get your technique to work. I wanted to created a shortcut to my solr directory. It currently lives in my: alias solr='cd /Applications/MAMP/htdocs/website/WhoAt/solr/whoat/' Perhaps my path isn't correct? – Leon Gaban Jun 10 '13 at 19:41
@Leon Are you using the bash shell? – Daniel Beck Jun 10 '13 at 20:45
I think I'm using default I think... – Leon Gaban Jun 10 '13 at 22:35

I know this is old, but this might help someone.

After you follow @Daniel Beck's answer above, and add the alias to the bash_profile like he mentioned, you have to type the following in the terminal window:

source .bash_profile

This will make all your aliases work.

I've got this from this answer on stack overflow. It has worked for me. I hope it works for someone looking for this...

How Do I create a terminal shortcut to this path?

share|improve this answer
Thanks, this came in handy. Also source ~/.bash_profile might be a more general way of writing it – mattsven Sep 15 '15 at 1:43

Another approach is to use the CDPATH environment variable.  This works for the cd command the way PATH works for running programs — if you type a cd command with a parameter that doesn’t begin with / (or ~), the shell looks for a directory by that name under each component of CDPATH.  For example, if you want quick access to the following directories:

  • /Users/benhowdle89/Documents/Projects/Project42
  • /Applications/MAMP/htdocs/website/WhoAt/solr/whoat
  • /the/quick/brown/fox/jumps/over/the/lazy/dog

then set CDPATH to the following value


and you’ll be able to use the commands cd Project42, cd whoat, and cd dog, etc.  The value begins with a colon (:) so as to include an initial null entry.  In some shells, this is necessary to get cd to look in the current directory first.

This should work in most POSIX-type shells; e.g., bash and ksh.  For bash, put a command like

export CDPATH=:/Users/benhowdle89/Documents/Projects:/Applications/MAMP/htdocs/website/…

into your ~/.bash_profile or ~/.bashrc.  (If you use ~/.bashrc, you may be able to leave out the export.)  For csh-type shells, use cdpath and the appropriate csh-style syntax.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.