Last active
April 14, 2023 19:50
-
-
Save james2doyle/53f4316d5f885b6f51119e086b660d99 to your computer and use it in GitHub Desktop.
Hammerspoon script to easily find the emails of the people I work with
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Name: Emails | |
Author: James Doyle <james2doyle@gmail.com> | |
Description: Easily find the emails of the people I work with | |
Demo: <None> | |
Installation: Just require this file in your Hammerspoon init.lua file | |
Usage: | |
Press the keybinding (ctrl+shift+E) and filter the results | |
Selecting one copies it to your clipboard | |
]]-- | |
-- Array to store the statuses | |
local data_table = {} | |
data_table["person.name@email.com"] = "Person Name" | |
-- etc... | |
-- etc... | |
-- etc... | |
local pasteboard = require("hs.pasteboard") -- http://www.hammerspoon.org/docs/hs.pasteboard.html | |
hs.hotkey.bind({"shift", "ctrl"}, 'E', function () | |
local chooser = hs.chooser.new(function(selection) | |
if selection.code ~= nil then | |
hs.eventtap.keyStrokes(selection.code) | |
pasteboard.setContents(selection.code) | |
end | |
end) | |
-- build a table of choices | |
local choices = {} | |
-- sort them by status code | |
for k,v in hs.fnutils.sortByKeys(data_table) do | |
table.insert(choices, { | |
["code"] = k, -- gets used for the copying | |
["text"] = v, -- shown to the user to filter | |
}) | |
end | |
chooser:choices(choices) | |
chooser:show() | |
end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment