Set Terminal Focus to Follow the Mouse Cursor in Mac OS X

Apr 18, 2011 - 12 Comments

Terminal window follow mouse cursor focus in Mac OS X

If you’re coming to Mac OS X from elsewhere in the unix & x11 world, you might be used to the focus of Terminal windows following your mouse cursor. With a little command line magic, we can enable this hidden feature in the Mac OS X Terminal.app too.


This requires the usage of a defaults write string, the syntax is slightly different depending on the version of OS X that is running on the Mac, but it’s supported in virtually every version of the Mac operating system that has the Terminal application.

Enable Mouse Focus for Terminal in Mac OS X Yosemite & Mavericks

Launch the Terminal and enter the following defaults write string:
defaults write com.apple.Terminal FocusFollowsMouse -string YES

You’ll then need to relaunch the Terminal app for the change to take effect.

To disable focus following the cursor, use the following string in modern versions of OS X:

defaults write com.apple.Terminal FocusFollowsMouse -string NO

Again, relaunching the Terminal for changes to take effect.

If you look carefully, you’ll notice the command for Terminal mouse focus in OS X Yosemite is nearly identical to prior versions, except you use a capitalized “T” in “com.apple.Terminal”.

Enable “Focus Follows Mouse” in Terminal for Prior Versions of OS X

Older versions of OS X, like Mountain Lion and Snow Leopard, can use the following terminal command string to enable mouse focus:

defaults write com.apple.terminal FocusFollowsMouse -string YES

You’ll now need to relaunch Terminal.app for changes to take effect.

If you don’t like it, you can disable cursor focus by changing YES to NO and reissuing the command:

defaults write com.apple.terminal FocusFollowsMouse -string NO

Then relaunch Terminal.app for the click-to-focus default setting to be enabled again.

Terminal in OS X

Finally, If you’re wondering what my super awesome background picture is, it’s the 8-bit pixelated aurora wallpaper.

.

Related articles:

Posted by: William Pearson in Command Line, Mac OS, Tips & Tricks

12 Comments

» Comments RSS Feed

  1. Bruce Sears says:

    Long time developer using Unix/Linux. Now working in a pure Mac shop (thank god, not Windows.)

    Best things lost were unix cli, mouse follows focus, and select copies text + middle click paste.

    Wish it was across all windows, ah, well…

    Both are now there at least in Terminal. And just hooray the underlying OS is unix :) !!

  2. lenooh says:

    Fantastic!
    Too bad it can’t be done for all windows.

  3. James says:

    Shame this command doesn’t work for all windows and apps. Also would be great if there was another command line to bring a window to the top.

    • Octupus says:

      You can use Command+1 Command+2 Command + 3 etc to bring specific windows to the top and be active, just remember which is which and you’ll be able t switch them easy

  4. a says:

    doesn’t work in yosemite

  5. […] osxdaily.com This entry was posted in Tweaks on my mac and tagged mac, terminal.app, tweak by […]

  6. ipatch says:

    This does bring the window to focus on OS X (10.7) as well. Is there a way to bring focus to the window, and then make it the top window, because right now this tweak just makes window focus, but does not make it the top window. I figure there is a another simple line to make the window the top window. BTW great tweak :D

  7. jv says:

    Hmmm…. not exactly what I was hoping for…. what I thought this meant was that if I entered a directory in finder that Terminal would choose the same directory. So, what does “focus” in this case mean? I don’t see any difference.

    • xf says:

      It doesn’t effect PWD, only that the focus of windows follows your mouse cursor. Think old school X11 window managers.

  8. Ian says:

    X11 style, great idea

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site