mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-26 07:15:37 +00:00
hammerspoon updates
This commit is contained in:
parent
ba75ec2366
commit
43cbd18caf
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
function fish_user_key_bindings
|
function fish_user_key_bindings
|
||||||
bind -M insert \co 'edit'
|
bind -M insert \co 'edit'
|
||||||
|
bind -M insert \ca 'cd; and edit; cd -'
|
||||||
bind -M insert \ce 'recent'
|
bind -M insert \ce 'recent'
|
||||||
bind -M insert \cg 'commandline-git-commits'
|
bind -M insert \cg 'commandline-git-commits'
|
||||||
bind -M insert \cf 'fcd'
|
bind -M insert \cf 'fcd'
|
||||||
|
@ -39,15 +39,20 @@ function obj:init()
|
|||||||
|
|
||||||
-- Control was not down but is now
|
-- Control was not down but is now
|
||||||
if not self.lastModifiers['ctrl'] then
|
if not self.lastModifiers['ctrl'] then
|
||||||
|
|
||||||
|
-- Only prepare to send escape if no other modifier keys are in use
|
||||||
self.lastModifiers = newModifiers
|
self.lastModifiers = newModifiers
|
||||||
if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then
|
if (not self.lastModifiers['cmd'] and not self.lastModifiers['alt']) then
|
||||||
self.sendEscape = true
|
self.sendEscape = true
|
||||||
self.movements = 0
|
self.movements = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Control was down and is up, hasn't been blocked by another key, and
|
-- Control was down and is up, hasn't been blocked by another key, and
|
||||||
-- isn't above the movement threshold
|
-- isn't above the movement threshold
|
||||||
elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 20) then
|
elseif (self.sendEscape == true and not newModifiers['ctrl'] and self.movements < 30) then
|
||||||
|
|
||||||
self.lastModifiers = newModifiers
|
self.lastModifiers = newModifiers
|
||||||
|
|
||||||
-- Allow for shift-escape
|
-- Allow for shift-escape
|
||||||
if newModifiers['shift'] then
|
if newModifiers['shift'] then
|
||||||
hs.eventtap.keyStroke({'shift'}, 'escape', 0)
|
hs.eventtap.keyStroke({'shift'}, 'escape', 0)
|
||||||
@ -56,8 +61,12 @@ function obj:init()
|
|||||||
end
|
end
|
||||||
self.sendEscape = false
|
self.sendEscape = false
|
||||||
self.movements = 0
|
self.movements = 0
|
||||||
|
self.numberOfCharacters = 0
|
||||||
|
|
||||||
|
-- Control was down and is up, but isn't ready to send escape
|
||||||
else
|
else
|
||||||
self.lastModifiers = newModifiers
|
self.lastModifiers = newModifiers
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
50
hammerspoon.symlink/Spoons/Launcher.spoon/init.lua
Normal file
50
hammerspoon.symlink/Spoons/Launcher.spoon/init.lua
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
--- === Launcher ===
|
||||||
|
|
||||||
|
local obj={}
|
||||||
|
obj.__index = obj
|
||||||
|
|
||||||
|
-- Metadata
|
||||||
|
obj.name = 'Launcher'
|
||||||
|
obj.version = '0.1'
|
||||||
|
obj.license = 'MIT - https://opensource.org/licenses/MIT'
|
||||||
|
|
||||||
|
function obj:init()
|
||||||
|
|
||||||
|
-- Begin launcher mode
|
||||||
|
self.launcher = hs.hotkey.modal.new('ctrl', 'space')
|
||||||
|
|
||||||
|
-- Behaviors on enter
|
||||||
|
function self.launcher:entered()
|
||||||
|
-- hs.alert'Entered mode'
|
||||||
|
end
|
||||||
|
-- Behaviors on exit
|
||||||
|
function self.launcher:exited()
|
||||||
|
-- hs.alert'Exited mode'
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use escape to exit launcher mode
|
||||||
|
self.launcher:bind('', 'escape', function() self.launcher:exit() end)
|
||||||
|
|
||||||
|
-- Launcher shortcuts
|
||||||
|
self.launcher:bind('', 'space', function() hs.hints.windowHints(); self.launcher:exit() end)
|
||||||
|
self.launcher:bind('', 'return', function() self:switch('Alacritty.app') end)
|
||||||
|
self.launcher:bind('', 'D', function() self:switch('Discord.app') end)
|
||||||
|
self.launcher:bind('', 'E', function() self:switch('Microsoft Outlook.app') end)
|
||||||
|
self.launcher:bind('', 'F', function() self:switch('Firefox.app') end)
|
||||||
|
self.launcher:bind('', 'G', function() self:switch('Mimestream.app') end)
|
||||||
|
self.launcher:bind('', 'M', function() self:switch('Messages.app') end)
|
||||||
|
self.launcher:bind('', 'O', function() self:switch('Obsidian.app') end)
|
||||||
|
self.launcher:bind('', 'P', function() self:switch('System Preferences.app') end)
|
||||||
|
self.launcher:bind('', 'R', function() hs.reload() end)
|
||||||
|
self.launcher:bind('', 'S', function() self:switch('Slack.app') end)
|
||||||
|
self.launcher:bind('', 'Z', function() self:switch('zoom.us.app') end)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function obj:switch(app)
|
||||||
|
hs.application.launchOrFocus(app)
|
||||||
|
self.launcher:exit()
|
||||||
|
end
|
||||||
|
|
||||||
|
return obj
|
||||||
|
|
@ -1 +1,2 @@
|
|||||||
hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon
|
hs.loadSpoon('ControlEscape'):start() -- Load Hammerspoon bits from https://github.com/jasonrudolph/ControlEscape.spoon
|
||||||
|
hs.loadSpoon('Launcher'):init()
|
||||||
|
@ -227,6 +227,7 @@ vim.api.nvim_exec([[
|
|||||||
au BufRead,BufNewFile *.toml.*link setfiletype toml
|
au BufRead,BufNewFile *.toml.*link setfiletype toml
|
||||||
au BufRead,BufNewFile *.muttrc setfiletype muttrc
|
au BufRead,BufNewFile *.muttrc setfiletype muttrc
|
||||||
au BufRead,BufNewFile .env* set ft=text | set syntax=sh
|
au BufRead,BufNewFile .env* set ft=text | set syntax=sh
|
||||||
|
au BufRead,BufNewFile *.hcl set ft=terraform
|
||||||
]], false)
|
]], false)
|
||||||
|
|
||||||
-- LaTeX options
|
-- LaTeX options
|
||||||
|
Loading…
Reference in New Issue
Block a user