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.

I open a lot of terminal windows. I also make use good use of tabs & multiple desktops.

Normally I launch Terminal.app with Spotlight. But if Terminal is already running on another desktop, it changes to that desktop and opens it there. I hate that. I want it to open on the current desktop.

So for now, I've been doing this:

Annoying!

Is there a better way?

share|improve this question
add comment

4 Answers

up vote 5 down vote accepted

By Golly, I think I've found it this time.

Fire up Utilities/AppleScript Editor. Copy/paste the lines below. Save it and add it to your Dock. Whenever you click it you'll get a new window on your current desktop. You need to have "Enable support for assistive devices" activated in System Preferences - Universal Access.

tell application "Terminal" to activate
tell application "System Events"
    tell process "Terminal"
        click menu item "New Window" of menu "Shell" of menu bar 1
    end tell
end tell

Source: adapted from this hint regarding Safari.

share|improve this answer
    
The first line of that script will switch you back to a space with a running terminal instance the moment it runs. –  NReilingh Aug 18 '10 at 2:22
    
It's not switching on my computer. Perhaps on account of having Terminal set up to follow me in "every space", although it's not actually following me in this case. –  intlect Aug 18 '10 at 2:28
    
The point of the question is that Terminal is already running in a different space. By definition, that can never happen if Terminal's following you everywhere you go. How did you manage to prevent Terminal from following you around when it's set to every space? –  NReilingh Aug 18 '10 at 3:40
    
Apparently, somebody (me) pressed the minus sign and removed Terminal from the list while playing around. So now every Terminal is stuck on its own desktop. Did you actually try the mini-script above? It definitely works for me. –  intlect Aug 18 '10 at 4:58
    
@intlect This does not work for me. It changes to the desktop Terminal is already running on. –  Adam Lassek Aug 18 '10 at 21:12
show 2 more comments

I looked far and wide and found no better way myself. I usually have less than 5 Terminal windows open, and I usually don't want to switch desktops for Terminal, so in System Preferences - Expose - Spaces I assigned Terminal to be in Every Space so as to follow me around. You might hate that though.

share|improve this answer
    
+1 for your trick but what if we want do the same thing for all application? it's better find a general solution. –  Am1rr3zA Aug 18 '10 at 0:10
    
No, sorry that would be equally annoying :) –  Adam Lassek Aug 18 '10 at 0:14
add comment

You can create a new service using automator (from the applications folder). At the top of the automator window, enter: Service receives 'no input' in 'any application'. Then, in the workflow, add 'Run applescript'. Make the applescript contain the following:

on run {input, parameters}

    tell application "Terminal"
        do script " "
        activate
    end tell

    return input
end run

(You can add any command you like into the do script line between the " " (e.g. something useful to run when terminal first opens like "uptime" if you like, or just leave it blank).

Save the service as 'Open Terminal' or whatever name you like. It should now appear in your services menu.

Then if you want to add a keyboard shortcut, you just need to go to System Preferences -> Keyboard -> Keyboard Shortcuts tab, select services in the left hand menu, and find your new service (its probably near the bottom). Just click in the space to the right of your service name, and assign it whatever keyboard shortcut you like, and hey presto! it should all work

share|improve this answer
add comment

You can tell the system to stop switching spaces "automagically" based on what App comes to the foreground:

# don't switch spaces
defaults write com.apple.Dock workspaces-auto-swoosh -bool NO
killall Dock

This is an important setting if you view each Space as its own workspace, and might have a Terminal window and a web browser window open in each space. If you want to switch spaces, you need to do so consciously and manually.

This is equivalent to System Prefs > Spaces, and then unchecking the "switch space when switching app" checkbox at the bottom.

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.