Skip to content

Instantly share code, notes, and snippets.

@iansinnott
Last active August 29, 2015 14:03
Show Gist options
  • Save iansinnott/2cbecf87d9273a0d5918 to your computer and use it in GitHub Desktop.
Save iansinnott/2cbecf87d9273a0d5918 to your computer and use it in GitHub Desktop.
Move windows around using Vim-style hotkeys
-- ~/.hydra/init.lua
-- This file requires boosh.lua, which can be found in my dotfiles:
-- https://github.com/iansinnott/dotfiles/tree/master/dotfiles/hydra
require "boosh"
-- The 'meta' key for window actions will be cmd+shift.
local meta = {"cmd", "shift"}
--- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
-- Dropdown GUI Menu
--- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
menu.show(function()
return {
-- Reload this file
{title = "Reload Config", fn = hydra.reload},
-- Menu horizontal rule
{title = "-"},
-- open a repl
-- the repl is a Lua prompt; type "print('hello world')"
{title = "Open REPL...", fn = repl.open},
-- Miscellaneous Hydra commands
{title = "-"},
{title = "About", fn = hydra.showabout},
{title = "Quit Hydra", fn = os.exit},
}
end)
--- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
-- Window Manipulation Functions
--- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
-- Full Screen
hotkey.bind(meta, "M", ext.grid.maximize_window)
-- Push or resize the window in a direction
hotkey.bind(meta, 'H', function() ext.grid.send_or_resize('left') end)
hotkey.bind(meta, 'J', function() ext.grid.send_or_resize('down') end)
hotkey.bind(meta, 'K', function() ext.grid.send_or_resize('up') end)
hotkey.bind(meta, 'L', function() ext.grid.send_or_resize('right') end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment