Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like a shortcut in my Dock that opens the Terminal window to a specific folder (the place where i store my development files). Is there a simple way to do this?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Fire up AppleScript Editor and put in the following script:

tell application "Terminal" to do script "cd /path/to/your/folder"

replacing /path/to/your/folder/ with the actual path of your folder. Then, go File - Save As (or Shift + Command + S), save with File Format Application, add it to your dock, and that's it! When you click that application, it will open up Terminal, cd to your directory, and you'll be ready to roll.

share|improve this answer

There are some general solutions available that use the current path in Finder, such as OpenTerminalHere and cdto.


You can accomplish your specific goal by using AppleScript:

tell application "Terminal" to do script "cd /your/path"

Save in AppleScript Editor as Script (right-hand side of the Dock) or application (left-hand side of the Dock). Side effect of the script is that it will always open a new Terminal window.


A little more sophisticated, opening a new tab only if necessary (depends on your preferences of course); this solution uses GUI scripting and might require support for assistive devices in Universal Access in System Preferences:

tell application "Terminal"
    activate
    set b to busy of selected tab of front window of application "Terminal"
    tell application "System Events"
        set x to count windows of application "Terminal"
        if x = 0 or b then
            keystroke "n" using command down # new window
        end if
        keystroke "cd /your/path"
        key code 36 # press enter
        keystroke "k" using command down # optional, clear scrollback
    end tell
end tell
share|improve this answer

I am not on OS X right now so I can't test this, but these ideas sprung to mind:

Make a shortcut (or script, and then shortcut to it) like this:

cd /path/to/your/folder && term

Where the path is to your folder and the correct command to launch the terminal is used.

If you only ever use the terminal in that way, you could put the cd (change directory) command into your bash profile, so whenever you open a new terminal it will go there.

share|improve this answer
1  
Terminal is a graphical application that ignores the working directory. –  Daniel Beck Dec 6 '10 at 3:36
    
My bad! I'm pretty new to OS X –  ZoFreX Dec 6 '10 at 4:23

Your Answer

 
discard

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.