Idea: Support mapping pre-defined phrases to snippets of text #162
Replies: 3 comments
-
|
@hesreallyhim feel free to chime in here, I know you have an implementation though it's slightly different Let's continue to get votes and feedback on this, as well as other thing's people might want so we can build an overall list and big picture. |
Beta Was this translation helpful? Give feedback.
-
|
@craigglennie so yeah i'm polishing up a branch on my fork where i've wired up a "System Commands" feature where you set a special trigger word/prefix, and then you can declare mappings from words to keyboard/system actions (Enter, Space, Newline, Paste, Undo, etc.). So e.g. if my prefix is "exec" I can say "Let's create a new line here exec newline and now we're on a new line." and it will print: So the I designed it as "System Commands" with the idea of OS-neutral commands, as in the actions are named semantically and not by actual keyboard key. But it uses the "enigo" library, and it looks like it's basically doing keyboard simulations with OS-detection (Codex wrote the implementation, so I'm reading through that part now). So there's definitely a lot of crossover between this and what you're suggesting. This is what the UI looks like currently:
So one idea that leaps out is to extend this UI so that you can add mappings and then design it (either based on two different trigger words or in the config (or both)) so that e.g. "install dev" maps to "npm install --save-dev" and then I can choose to either TRANSCRIBE the mapped phrase or EXECUTE the mapped phrase (maybe i have a "handy-print" and a "handy-run" prefix e.g.), since all of my "system commands" are really "under-the-hood" calls to keystrokes anyway. I chatted a little with Codex about this (Codex wrote the implementation) and I think we can design something that is a medium-complexity enhancement of what I built (which Codex wrote in just two days). So actually I think it's a very cool idea, and very doable. There are still a few "quirks" in my implementation that I would want to iron out first, and maybe "ship" some version of what I built first, but I would definitely see the possibility of adding this as an enhancement to what I wrote, and something I would also find useful and cool. |
Beta Was this translation helpful? Give feedback.
-
|
Doable with #930 #!/usr/bin/env python3
import sys
text = sys.stdin.read()
# Command expansions and emoji shortcuts
replacements = {
# Commands
"run unit tests": "pnpm run tests",
"run tests": "pnpm run tests",
"run dev": "pnpm run dev",
"run build": "pnpm run build",
"git status": "git status",
"git commit": "git commit",
# Emojis
"grin emoji": ":grin:",
"smile emoji": ":smile:",
"thumbs up emoji": ":thumbsup:",
"heart emoji": ":heart:",
"fire emoji": ":fire:",
"rocket emoji": ":rocket:",
"eyes emoji": ":eyes:",
"party emoji": ":tada:",
}
# Strip punctuation for lookup
lookup_text = text.strip().lower().rstrip('.,!?;:')
sys.stdout.write(replacements.get(lookup_text, text)) |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to be able to say a pre-defined phrase to Handy and have it enter a pre-defined piece of text that I have configured in the Handy UI.
Some examples:
I want to run all my unit tests so I focus on my terminal and say "run unit tests" and Handy enters "pnpm run tests" just as if I had dictated "pnpm run tests" (which doesn't currently work because it transcribes to "P N P M run tests"
I want to react with a favourite smiley emoji in Slack so I press Cmd+Shift+\ to open the emoji reaction modal and say "grin emoji" and it inserts ":grin:" into the search box
My idea would be to have a screen in Handy with a form where you could create, edit and delete these mappings.
I think it might have a separate keyboard shortcut but it could live on the current shortcut and simply scan any existing mappings before outputting the transcribed text, and if you have a mapping then that replaces what you said.
Note: The idea is not to turn Handy a general purpose automation or voice-control tool. With that in mind I've tried to keep this idea as minimal and simple as possible.
Beta Was this translation helpful? Give feedback.
All reactions