Using multiple monitors improves efficiency by avoiding switching back and forth between task Windows or applications. However, with the expansion of the workspace, there are other problems, including:

  1. The efficiency of using the mouse is further reduced;
  2. Too many active Windows tend to lose focus;
  3. More often than not, both are happening at the same time: it’s hard to find where the mouse pointer is, and it’s harder to drag between screens and manage Windows.

Whether you’re a VIM or not, constantly switching between mouse and keyboard is distracting and inefficient, and many lazy people would rather spend their time memorizing a huge number of keyboard combinations. (That’s fine if you can’t, but here’s a handy cheat to help you quickly check the current app’s keyboard shortcuts: Cheatsheet) and would not let his right hand leave the keyboard.

Although in order to avoid the use of the mouse you can even VIM mapping fitted on Chrome plug-ins, but sometimes have to rely on complete some precise click of the mouse and drag operation, however, according to the psychological physics famous fitts law (Fitt ‘s law), the mouse movement time is proportional to the target distance, and the target is inversely proportional to the size:

This means that as the workspace expands, using the mouse becomes less and less efficient. In addition to the mouse problem, when multiple app Windows are open in front of you at the same time, it’s easy to get confused about which app is currently capturing the focus, even if you’re trying to combine shortcuts. Of course, even if multiple Windows overlap, you can determine the current focus by looking at the name of the app displayed in the upper-left toolbar, but Fitz’s law also applies to visual search, and for those who don’t even bother to look up, it’s better to try switching between Command and Tab to find the app in the current focus.

But this problem can be solved with another cheater: the HazeOver

It makes the window currently in focus appear normally, while all other Windows are covered with a translucent black veil:

MacOS offers an interesting little feature that allows you to position your mouse quickly by making the cursor zoom by shaking it quickly. However, this small amount of work is far from making up for its shortcomings in window management. Dock with Windows on the welt, jilt a dump compared to other Windows functions, macOS red yellow green left upper corner of the window had little sense of three dots, aside from area is too small not easy click, green zoom button can only enter or exit full screen mode, although later joined the long press enter full screen mode, and is basically a chicken ribs: It doesn’t work on a small laptop, and it doesn’t work when you have an extended screen. As a result, there are many third-party solutions emerging from Apple’s strong ecological appeal, but my needs are very simple. I don’t see any need to divide a screen into dishes, fields, etc. I just need the simplest features:

  1. Can be maximized but not full screen;
  2. Can occupy the left half or the right half;
  3. It can move quickly between different displays.

The first two are basic Windows features, and after trying out a few window management apps, I settled on Hammerspoon, which can be configured precisely in code. Unlike other tools, it is open source and uses Lua scripts as configuration files.

Lua, save to ~/. Hammerspoon /init.lua, and Reload Config. Hammerspoon also offers a Console interface for easy debugging:

Configuration File Description

Shift + Command +?
local hyper = {'shift'.'cmd'}

-- Maximize window
The shortcut keys are Shift + Command + ↑
hs.hotkey.bind(hyper, 'up'.function(a)
    hs.grid.maximizeWindow()
end)

-- Make the window occupy the left half (dock to the left edge under Windows)
-- The shortcut keys are Shift + Command + ←
hs.hotkey.bind(hyper, "Left".function(a)
  local win = hs.window.focusedWindow()
    local f = win:frame()
    local screen = win:screen()
    local max = screen:frame()

    f.x = max.x
    f.y = max.y
    f.w = max.w / 2
    f.h = max.h
    win:setFrame(f)
end)

-- Docking to the right is similar

Move the current window to the NTH screen
-- and maximize the window
The shortcut keys are Ctrl + Command + screen number
local hyper2 = {'ctrl'.'cmd'}
moveto = function(win, n)
  local screens = hs.screen.allScreens()
  if n > #screens then
    hs.alert.show("No enough screens ". #screens)else
    local toWin = hs.screen.allScreens()[n]:name()
    hs.alert.show("Move ". win:application():name() .." to ". toWin) hs.layout.apply({{nil, win:title(), toWin, hs.layout.maximized, nil.nil}})
  end
end

hs.hotkey.bind(hyper2, "1".function(a)
  local win = hs.window.focusedWindow()
  moveto(win, 1)
end)
hs.hotkey.bind(hyper2, "2".function(a)
  local win = hs.window.focusedWindow()
  moveto(win, 2)
end)
hs.hotkey.bind(hyper2, "3".function(a)
  local win = hs.window.focusedWindow()
  moveto(win, 3)
end)Copy the code

View the screen recording effect.