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.

link|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. – hesse Jan 5 at 20:13
Check out github.com/joelthelion/autojump/wiki, it might also work for you. – Daniel Beck Jan 5 at 20:18
feedback

1 Answer

up vote 1 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'

This works from any directory, but requires the bash shell (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 only work when you're in your home directory to start with (cd without arguments takes you there quickly).

link|improve this answer
cd as cd ~ is my favorite alias. – Rob Jan 5 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 at 20:36
feedback

Your Answer

 
or
required, but never shown

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