Skip to content

Instantly share code, notes, and snippets.

@yspreen
Created January 10, 2020 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yspreen/373dd691977eb85bb1d493878797c43c to your computer and use it in GitHub Desktop.
Save yspreen/373dd691977eb85bb1d493878797c43c to your computer and use it in GitHub Desktop.
do_cut = false
fc = function()
hkc:disable()
if hs.window.focusedWindow():application():bundleID() == "com.apple.finder" then
hs.eventtap.keyStroke({"cmd"}, "C")
do_cut = false
else
hs.eventtap.keyStroke({"cmd"}, "C")
end
hkc:enable()
end
fx = function()
hkc:disable()
hkx:disable()
if hs.window.focusedWindow():application():bundleID() == "com.apple.finder" then
hs.eventtap.keyStroke({"cmd"}, "C")
do_cut = true
else
hs.eventtap.keyStroke({"cmd"}, "X")
end
hkc:enable()
hkx:enable()
end
fv = function()
hkv:disable()
if hs.window.focusedWindow():application():bundleID() == "com.apple.finder" then
if do_cut then
hs.eventtap.keyStroke({"cmd", "alt"}, "V")
else
hs.eventtap.keyStroke({"cmd"}, "V")
end
do_cut = false
else
hs.eventtap.keyStroke({"cmd"}, "V")
end
hkv:enable()
end
hkc = hs.hotkey.new({"cmd"}, "C", fc)
hkc:enable()
hkx = hs.hotkey.new({"cmd"}, "X", fx)
hkx:enable()
hkv = hs.hotkey.new({"cmd"}, "V", fv)
hkv:enable()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment