Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.3: Switch Terminal window focus with mouse movement Apps
A feature that I've long waited for -- window focus that follows the mouse between terminal windows -- has finally been added (in a hidden manner) to the 10.3 Terminal application. From the Terminal, type:
defaults write com.apple.Terminal FocusFollowsMouse -string YES
Quit and restart the Terminal and enjoy! Now if I only had window autoraise, I'd be in heaven!

[robg adds: I know a bunch of Linux/X11 users who are gonna love this one! If you don't like it, though, just re-do the command with NO at the end. Or if you're really paranoid about excess items in prefs files, you can remove the default entirely with defaults delete com.apple.Terminal FocusFollowsMouse.]
    •    
  • Currently 3.10 / 5
  You rated: 5 / 5 (10 votes cast)
 
[72,419 views]  

10.3: Switch Terminal window focus with mouse movement | 30 comments | Create New Account
Click here to return to the '10.3: Switch Terminal window focus with mouse movement' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.3: Switch Terminal window focus with mouse movement
Authored by: mithras on Oct 31, '03 10:41:51AM
Or, in this spirit of the new Applescript links:
  1. Click to enable window box
  2. When Script Editor opens, click the greeb Run button:

When you're done playing, click to disable the effect

---
--
Listen To My iTunes Library (6500+ songs, iTunes 4 required)

[ Reply to This | # ]

wrong hint!
Authored by: jvr on Oct 31, '03 11:19:31AM

This applescript link comment should be under the "Show Desktop" hint; not this one.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: vancenase on Oct 31, '03 11:22:44AM

1. does this work with the X11 term, and not just the apple 'terminal'?

2. does this support 'focus follows mouse' or 'focus under mouse'? i have not tested this yet, but i'd rather it not bring the window in focus to the front ... ?



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: vancenase on Oct 31, '03 11:24:45AM

i guess i noticed this hint is for the 'apple terminal'. is there a similar feature (like the one i described above) for the X11 term, and X11 'apps' in general?



[ Reply to This | # ]
X11: It depends on your window manager...
Authored by: terceiro on Oct 31, '03 11:42:01AM

Actually, focus-follows-mouse is the default behavior for X11. It is *not* the behavior of quartzwm, however. To test this, make a .xinitrc file with no window manager but do include one (or two) xterms. You'll see that, even with no window manager running, the focus does indeed follow the mouse. (This might only work in full-screen mode).

Just for fun, I'm running a full KDE installation under a full-screen Apple X11, and it works great -- including virtual desktops! I can switch between click-to-focus and focus-follows-mouse at will, easy as pie.

FWIW, I dislike focus-follows-mouse, simply because I'm not used to it.



[ Reply to This | # ]
X11 focus-follow mouse option
Authored by: kal on Oct 31, '03 12:53:10PM

To turn on focus follow mouse in X11:

defaults write com.apple.x11 wm_ffm true



[ Reply to This | # ]
X11 focus-follow mouse option
Authored by: vancenase on Oct 31, '03 12:56:56PM

thanks kal. does this bring the window the mouse is under forward .... or not (preferred)?

thanks!



[ Reply to This | # ]
X11 focus-follow mouse option
Authored by: kal on Oct 31, '03 01:18:59PM

The window is not moved to the front, but the "keyboard focus" is changed. If you want to move the window to the front you will have to left-click as well. I think this can be achieved in jaguar as well, btw...



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: TvE on Oct 31, '03 01:18:12PM

I did'nt think that Terminal "geeks" (a positive somment - I am trying to become one myself ;-) would be using a mouse a lot.


Why not use the "default" keyboard shortcuts in OS X (also available in 10.2) to change focus to the windows within the launched application (Micro$oft excluded - they do things in their own strange ways...)

COMMAND-< and COMMAND-> cycles between the windows.

Of course - if you have 10 open windows in terminal it would be faster to use the mouse, but if you only have 3 or 4 - I'd go for the keyboardshortcuts



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: osxpounder on Oct 31, '03 03:25:00PM

On my 10.3 box, CMD-> and CMD-< do not cycle windows, at least not in some apps.

In Safari, CMD-< brings up its Preferences; same thing happens in Terminal and in Finder. In Terminal, CMD-> looks like it does the same thing as pressing the ENTER key.

---
--
osxpounder



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: babbage on Nov 19, '03 03:02:27PM

He didn't literally mean the [>] (greater than) and [<] (less than) keys -- he meant the left & right arrows. If you go into the "Window" menu under Terminal.app, the relevant keystrokes should be indicated for you:

    [cmd]+[right arrow]  next terminal
    [cmd]+[left arrow]   previous terminal
    [cmd]+[M]            minimize window to dock
    [cmd]+[1]            go to terminal/tty 1
    [cmd]+[2]            go to terminal/tty 2
    [cmd]+[3]            go to terminal/tty 3

Etc. That last set is especially useful, particularly if you've gone into Terminal.app's "Window Settings..." option menu, then the "Window" subsection in that dialog box, and checked off "Command key" as one of the window titlebar options.

If you keep your terminal windows just barely overlapping, so that the titlebars are all cascaded and you can see at least part of the left (preferably) or right margin of the window, then you can quickly see & jump to any currently open window by hitting [cmd]+[number key of that window] -- and if the window you want is currently minimized to the dock, it'll pop back onto the desktop too. Useful trick.

---
--
DO NOT LEAVE IT IS NOT REAL

[ Reply to This | # ]

10.3: Switch Terminal window focus with mouse movement
Authored by: ashill on Oct 31, '03 03:51:38PM

One advantage of focus follows mouse in the Terminal (and X11) is that the window with focus does not come to the foreground, so if I'm entering commands in a terminal that I don't need to see much of but one to refer to another terminal, that one stays on top, even though it's in the 'background.' To bring the window to the top, click in it.

(cmd-` is the shortcut to rotate through windows in most applications. cmd-left arrow and cmd-right arrow also work in Terminal.)



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: rootpoot on Oct 31, '03 04:53:34PM

If you have ten open Terminal windows, you need to be using screen anyway...



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: Anidel on Oct 31, '03 02:13:22PM

Here I am! Linux/X11 user and...I LOVE THIS! :)

---
Anidel



[ Reply to This | # ]
Work with other Apps?
Authored by: ngb on Oct 31, '03 09:58:59PM

Is this something that could be turned on system wide? I seem to remember the Public Beta of OS X had this behavior.



[ Reply to This | # ]
And...
Authored by: thinkyhead on Nov 01, '03 07:29:42AM

This works even if Terminal isn't the active application, which makes it really convenient to paste text into the Terminal from other apps.

This hint is especially valuable on laptops where your hand is already over the trackpad - in contrast to the desktop where you have to reach for the mouse. If you're already keyboarding away, it's far more convenient to simply use Command-` or Command-1 thru 9 to switch windows.

---
|
| slur was here
|



[ Reply to This | # ]
And...
Authored by: maparent on Nov 30, '03 10:58:56AM

But this has serious downsides... Example: If I switch to a windowless application with Cmd-Tab, and then do a new window, I have to first move my mouse away from the terminal windows littering my screen, or I'll just get a new one!
I wish I could adjust that last behavior.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: eerno1 on Nov 02, '03 10:11:45AM
I've found the defaults command useful for things like this. I'd find it even more useful if I knew how to list the available keys for individual applications. For example, if you enter the command, defaults read com.apple.x11 you won't see FocusFollowsMouse unless you've already set it to something. How do you get a list of what can be set using the defaults command?

[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: aranor on Feb 24, '04 04:02:51AM

Umm, you can't. The closest you can come is doing a strings on the actual executable and looking for anything that resembles a preferences key.



[ Reply to This | # ]
Hint does not work
Authored by: macubergeek on Nov 03, '03 03:41:56PM

Sorry
Hint flat out dosn't work in Panther. Just tried it, and verified it by more'ing com.apple.Terminal.plist file to verify setting to YES

While the setting is there and set to YES the feature does not work.



[ Reply to This | # ]
Hint does not work
Authored by: macubergeek on Nov 03, '03 03:46:03PM

ok i figgered out the secret trick


first delete your existing Terminal preferences and then run the command THEN it'll work.



[ Reply to This | # ]
Hint does not work: need capital Mouse
Authored by: frogbyte on Nov 03, '03 06:43:13PM

I had it working on my iBook but could not get it working on my powerbook until i did a diff on the two .plist files. I found the answer: "FocusFollowsMouse" capital "Mouse"

works now!



[ Reply to This | # ]
Mirrored in Terminal.plist
Authored by: thinkyhead on Nov 06, '03 07:53:54PM

This setting is mirrored in Terminal's preferences file and it doesn't get turned off by deleting the global key. You don't need to delete the com.apple.terminal.plist file, simply remove the two lines that refer to FocusFollowsMouse.

---
|
| slur was here
|



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: u2mr2os2 on May 06, '05 10:32:33PM

Be careful using this with Terminal. It will steal input focus from other apps if you pass over a Terminal window in the background. This isn't too annoying in itself, but it's really a problem if you are trying to select from a menu (main or popup) and pass over a Terminal window in the background - it will cancel the menu. An especially annoying case of this is if you have a Terminal window that is down by the Dock, and use a right-click menu on a dock item. The popup menu has a gap between the Dock and the menu, and if a Terminal window is behind that gap, it will cancel the popup menu if you pass over the gap. You have to carefully move the mouse up to the popup menu in the middle where the pointy menu bottom bridges the gap.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: Peter Kappesser on Aug 17, '05 12:34:01AM

This also causes problems if you need to save the text from a terminal window, and you have several open -- unless you've memorized the keyboard shortcut for that flavor of saving (I can never remember if it's option-command-S or shift- or whatever), when you move your mouse to use the menu, the focus changes and you may end up saving the text from the wrong window, which just happened to me tonight.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: hankk on Sep 21, '09 10:16:18AM

I've used this tip for many years, but it is effectively broken with 10.6 Snow Leopard in many cases. I find that if I am using Terminal, and use Command-Tab to switch to an application *in a different space*, then the application switches, but the space does not. This effectively leaves things unchanged, and doesn't switch you where you want to go.

If you turn off the focus-follows-mouse defaults, as per the original posting, then the behavior works as it should.

Oddly, using Launchbar to switch applications *does* work. But I like using Command-Tab at times, so I had to turn off focus-follows-mouse.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: Kludge on Mar 20, '11 09:57:02AM

It seems like it's fixed in 10.6.6 so you should start using it again.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: Garex on Aug 12, '10 03:33:19PM

In Snow Leopard I discovered some not-so-nice effect:

Open Safari on Spaces desktop two and Terminal on number three. When you now change from Terminal.app to Safari using the Spaces hotkey function (CTRL-3, klick in Terminal window, CTRL-2), then the mouse focus will stay in Terminal.app. If you are a keyboard fanatic as I am, you will use CMD-L in Safari to enter new URL or search terms. Instead of them entered in Safari, they are entered in Terminal.app and not in Safari! Just imagine searching for "rm -rf /" and then hitting enter. :)

Therefore I disabled this feature again.

Yours,

Martin



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: Tiger_T_X on Feb 22, '11 08:37:34AM

On 10.6 Snow Leopard, the defaults did not work but inserting into Terminal.plist works.
Thanks.



[ Reply to This | # ]
10.3: Switch Terminal window focus with mouse movement
Authored by: Kludge on Mar 20, '11 10:01:41AM

The reason it doesn't work is the guy didn't bother to actually look at the value he's changing. It's not a string it's a boolean. The correct code is:

defaults write com.apple.Terminal FocusFollowsMouse -boolean YES

The bug mentioned about command-tab switching with spaces has been fixed in 10.6.6 so there's no reason not to use the focus-follows-mouse in terminal. It's saved me all sorts for grief and having to correct my code window when I accidentally type in there instead of my terminal window.



[ Reply to This | # ]