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.

Is there any functionality in Chrome, iTerm2, or a keyboard shortcut app that will let me open a new window (Chrome or iTerm2) in a global environment?

It should open a new window regardless of whether previous windows exist or not.

share|improve this question
    
Cmd-N opens a new Chrome window, are you looking for something else? –  patrix Jun 14 '12 at 20:35
    
Yes, Cmd-N only works when you have Chrome focused. I'm looking for a global keyboard shortcut that works even if you have a different application focused (say, Finder). –  Artem Shnayder Jun 14 '12 at 22:37
    
Do you want it to open a window in Chrome or in iterm2? The answer will obviously be different depending on what you want it to do. –  Daniel Lawson Jun 15 '12 at 3:53
    
One keyboard shortcut for Chrome, another one for iterm2. I'm guessing the process is the same. –  Artem Shnayder Jun 15 '12 at 18:08

2 Answers 2

up vote 3 down vote accepted

To make a single hotkey always create a new Chrome window, launch Automator. Tell it to create a new Service Have the service take no input. Assign a single action to the service: Run AppleScript (in the Utilities list of actions).

Here is the AppleScript:

on run {input, parameters}
    tell application "Google Chrome"
        activate
        delay 0.1
        make new window
    end tell
    return input
end run

Save the service with a name like "New Chrome Window". Then, in System Preferences assign an unused keyboard shortcut to the service. You can then create a new Chrome window no matter what application you are in.

To improve the service substantially, replace "Google Chrome" with "Safari". :-)

To create a new window in a different scriptable app, replace "Google Chrome" with the name of the app you want to create a new window.

enter image description here

share|improve this answer
    
Is there a way to tell Chrome to activate just the new window that was created and not the whole application? –  Artem Shnayder Jun 16 '12 at 18:47
1  
That would be the Holy Grail for many AppleScripters, and the answer appears to be sadly, no. I'd love to be wrong about that, but I've been hunting a long time and there is no obvious way to do it, and I've ruled out a lot of the non-obvious things to try also. –  Daniel Lawson Jun 16 '12 at 19:20
    
This answer should include the iTerm2 snippet from Lauri's answer as well. –  Artem Shnayder Jun 18 '12 at 4:42
    
I use multiple spaces and this causes it to switch to a space where chrome is already open and open a new window there. I fixed it by removing the two lines "activate; delay 0.1", which works for me since I always have chrome open anyways. –  vish Jul 3 '13 at 22:41

Save these scripts somewhere in AppleScript Editor and assign shortcuts to them with an application like Alfred or FastScripts.

make new window or make new document often opens a new window:

tell application "Google Chrome"
    make new window
    activate
end tell

http://code.google.com/p/iterm2/wiki/AppleScript

tell application "iTerm 2"
    tell (make new terminal)
        launch session "Default"
    end tell
    activate
end tell

There's a bug where shortcuts for Automator services don't always work until the services menu has been shown once from the menu bar. Automator services also have small delays and they don't work when the frontmost application doesn't have a menu bar or a services menu.

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.