Skip to content

Instantly share code, notes, and snippets.

@STRML
Created July 10, 2015 14:14
Show Gist options
  • Save STRML/96adae1c6c3757d35f74 to your computer and use it in GitHub Desktop.
Save STRML/96adae1c6c3757d35f74 to your computer and use it in GitHub Desktop.
Lua snippet for Hammerspoon to bind ctrl-tab and ctrl-shift-tab back to switching channels.
--
-- Fix Slack's channel switching.
-- This rebinds ctrl-tab and ctrl-shift-tab back to switching channels,
-- which is what they did before the Teams update.
--
-- Slack only provides alt+up/down for switching channels, (and the cmd-t switcher,
-- which is buggy) and have 3 (!) shortcuts for switching teams, most of which are
-- the usual tab switching shortcuts in every other app.
--
local ctrlTab = hotkey.new({"ctrl"}, "tab", function()
hs.eventtap.keyStroke({"alt"}, "Down")
end)
local ctrlShiftTab = hotkey.new({"ctrl", "shift"}, "tab", function()
hs.eventtap.keyStroke({"alt"}, "Up")
end)
slackWatcher = hs.application.watcher.new(function(name, eventType, app)
if eventType ~= hs.application.watcher.activated then return end
if name == "Slack" then
ctrlTab:enable()
ctrlShiftTab:enable()
else
ctrlTab:disable()
ctrlShiftTab:disable()
end
end)
-- If you re-init config often, be sure to stop() this before starting or you will
-- have multiple application watchers running at once.
slackWatcher.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment