[hammerspoon] Add mash shortcuts for throwing windows to the left and right
change
commit 443ac26ab19206761c62ceddb11888497c0ecbc1
author Alpha Chen <alpha.chen@gmail.com>
date
parent acab0a57
diff --git a/.hammerspoon/init.lua b/.hammerspoon/init.lua
index 64bfc621..77c53adc 100644
--- a/.hammerspoon/init.lua
+++ b/.hammerspoon/init.lua
@@ -1,9 +1,41 @@
+local mash = {"cmd", "alt", "ctrl"}
+
+-- Application shortcuts
+
 hs.hotkey.bind({"cmd", "shift"}, "{", function()
-    current_app():selectMenuItem({"Window", "Select Previous Tab"})
+  current_app():selectMenuItem({"Window", "Select Previous Tab"})
 end)
 
 hs.hotkey.bind({"cmd", "shift"}, "}", function()
-    current_app():selectMenuItem({"Window", "Select Previous Tab"})
+  current_app():selectMenuItem({"Window", "Select Previous Tab"})
+end)
+
+-- Window management
+
+hs.hotkey.bind(mash, "h", function()
+  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)
+
+hs.hotkey.bind(mash, "l", function()
+  local win = hs.window.focusedWindow()
+  local f = win:frame()
+  local screen = win:screen()
+  local max = screen:frame()
+
+  f.x = max.x + (max.w / 2)
+  f.y = max.y
+  f.w = max.w / 2
+  f.h = max.h
+  win:setFrame(f)
 end)
 
 function current_app()