Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

With the URL <file:///Library/Fonts> (for example in a note in NV) I can open the finder with the given location. Can I do something similar for the terminal? That is, if I write for example (doesn't work, that is the question!) <terminal://Library/Fonts> the Terminal.app should open a new window and cd to that directory.

share|improve this question
1  
Not without writing your own URL handler. I strongly recommend against it as it opens quite a security hole (unless you are really careful and know what you are doing). –  patrix Apr 17 '12 at 17:44
    
The term you're looking for is a "protocol handler". It looks like you might be able to achieve what you want with a bit of AppleScript to wrap Terminal.app; see this Apple Discussion thread. –  Mathew Hall Apr 17 '12 at 17:45
    
Thanks to you both. While I don't mind writing code I'll put this on hold for a while. I was silently hoping for a out of the box solution. If one of you put your comment into an answer I'd be happy to mark that as accepted. –  topskip Apr 17 '12 at 18:05
    
“if I write” If you write it where? In a text file? In a shell script? At the command line? –  Chris Page Jul 20 '12 at 7:55
    
@ChrisPage for example on the open command line: open file:///foo/bar or (as I wish) open terminal://Library/Fonts –  topskip Jul 21 '12 at 19:34

3 Answers 3

Opening a New Terminal Interactively

As of Mac OS X Lion 10.7, Terminal has a “New Terminal at Folder” Service you can enable in:

System Preferences > Keyboard > Services > Files and Folders

With this Service you can open a new terminal by selecting a folder or file path in any application and choosing this Service in the contextual menu (Control-Click or Right-Click) or the Services submenu in the application menu.

It doesn’t support “file:” URLs, but you can select the path part of the URL “/Library/Fonts” and use the Service with that.

There is also a “New Terminal Tab at Folder” Service.

Opening a New Terminal Programmatically

If you need to open it from a command line or shell script, you can use the open command to tell Terminal to open a directory pathname or “file:” URL:

open -a Terminal file:///Library/Fonts

(This is equivalent to dragging a folder, file path or “file:” URL onto the Terminal application, which opens a new Terminal at that location.)

share|improve this answer

This works from the command line:

/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal /Users/ &

Where /Users/ is the directory you want to set the working directory to.

share|improve this answer
    
I don't see how I could turn this into a URL?! –  topskip Apr 17 '12 at 17:22
    
Sorry, I misread what you were trying to do. You'd have to register a URL handler somehow. stackoverflow.com/questions/595481/… Looks like Terminal supports ssh, telnet, and x-man-page, but nothing else right now. –  Bill Brasky Apr 17 '12 at 21:21

Try the open command:

  • open . opens Finder window for current directory
  • open /Library/Fonts opens Finder window for /Library/Fonts
  • open http://www.apple.com/
  • open ~/Documents/my-big-novel.pages

Run man open for additional options.

share|improve this answer

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.