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'm trying to make (1) special key open new terminal window.

I bound it to file /Users/taw/bin/new_term, which contains:

#!/bin/sh
exec osascript -e 'tell application "Terminal" to do script "cd ."'

This does the trick, except it also opens a Terminal window with this (even though Terminal.app is configured to always close windows when processes finish):

Last login: Thu Mar 11 19:41:29 on ttys000
/Users/taw/bin/new_term ; exit;
~$ /Users/taw/bin/new_term ; exit;
tab 1
logout

[Process completed]

How do I make it all work correctly? (possibly using a way different that what I've been attempting so far)

share|improve this question
add comment

3 Answers

Because the Microsoft IntelliType Pro software on OS X uses the open command to run whatever you ask it to, it can be difficult to get it to execute arbitrary AppleScript code.

I found that while shell scripts and the like don't work, if you create an Automator (not AppleScript) application with a single Action Run AppleScript you can then point IntelliType to run your Automator Application. Be sure you create an Application, not a Workflow.

I wanted a favorites key to control iTunes, so I used the following inside my Run AppleScript Action, which worked.

on run {input, parameters}

    tell application "iTunes" to next track

    return input
end run
share|improve this answer
add comment

Have your special key execute /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal instead.

(Out of curiosity, how are you binding a key to a command?)

Edit:

I try to keep anything Microsoft away from Mac OS, because they don't really seem to grok the Mac way. The fact that it's using open for everything is proof of this.

So, if I were you, I'd rip out the Microsoft keyboard driver, and use Spark instead:

http://www.brighthub.com/computing/mac-platform/reviews/30244.aspx

If you really want to use AppleScript to do what you're doing, perhaps this will be of use:

http://lambie.org/2007/11/03/tabs-in-terminal-using-applescript-on-leopard/

You could also snag some of the AppleScript from the latter link and trigger it with a hotkey using Spark.

share|improve this answer
    
Microsoft Keyboard drivers let me bind special keys (or any keys) to arbitrary file or URL. I think it tries to open the file using generic open command. Starting /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal seems to start a new process - not what I want. And then it opens the same window [Process completed] window. –  taw Mar 11 '10 at 20:31
    
Spark doesn't see special keys on Microsoft Keyboard at all. –  taw Mar 11 '10 at 22:58
    
So then don't use the special keys. Use command-control-0 or whatever you want. –  Alexander Burke Mar 12 '10 at 7:51
add comment

Use one of the options to start a program or execute a script without opening Terminal I describe in this answer.


To open a new terminal window, or just Terminal with a default window, you can try to adapt this solution.

share|improve this answer
add comment

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.