Closed sindresorhus closed 7 years ago
Something like this is useful for all the times I need to pull up an emoji: https://github.com/huyhong/emoj/commit/3fbf802e4ccb6dd00ec0a5f65de2b0ec111bc51f
Yes, I think a combination of keypress to listen for hotkeys like Ctrl + 1 and copy-paste to get the value into the clipboard would be all you need to pull this off.
Yeah, I know how to implement it. That's easy :) Just looking for feedback on the UI and the interaction.
+1
I see myself copying the whole row just to pick out and keep the ones I like, not only 1. but it might just be me.
@zwacky What if you could do for example Ctrl+1, Ctrl+2 to copy multiple.
could work if you keep holding down ctrl
and press numbers to add them to the clipboard.
as soon as you press ctrl
anew, the clipboard will start fresh.
not sure if this is super intuitive but a one liner could explain this pretty well.
@zwacky Yeah, happy to consider other ways of doing it, but I don't think most would want 7 emojis copied to their clipboard and manually having to delete the ones they don't want.
Would also like command
+ click
.
I imagine the majority of people already have command
+ a number already bound... especially if they've left their terminal prompts with default settings.
Why not simply leave it as pressing the number to select that emoji?
Once the number key has been pressed, those emoji will be "selected" (indicated by a color change for that number) and pressing enter will copy the selected emoji. 1, 2, 5, RETURN
@matchai Or a number(s) followed by native copy.
1, 2, 5, CMD+C
I like @matchai's approach. That's good UX. You have a confirmation/guiding UI.
I don't like the approach of just pressing a number without a control key of some sort, seems pretty invasive without it. If I have something important in my clipboard, and then I go to search for the 💯 emoji, then my important clipboard data will be replaced by a random emoji, which would make me mad. I like the deliberate (intentional) approach of mapping a control key to the hotkey, like CTRL + 1 because these type of hotkeys will never get in the way of what I might be typing into the emoj
prompt, or accidentally nuke the contents of my clipboard with a single keystroke.
Though, I may have misunderstood. If "Once the number key has been pressed" actually means "Once the number printed to the terminal has been clicked", then I like this idea, but I would say that in this case, the numbers are not necessary. Simply clicking or double-clicking on the emoji character to copy the character into the clipboard would be cleaner. The highlight to show the selected value (per @matchai's suggestion) would be a nice touch.
@radiovisual I did not mean clicking on the emoji being selected. I'm personally not a fan of having a primary input method being a mouse-click on a CLI app. I do think it would be a great as an additional input method for those who like that UX.
I totally understand why you'd want to avoid using numbers for selections. I totally oversaw the use case where a user would be inputting numbers into their strings. I still don't think CTRL + 1 is the right answer though. CTRL + Number is commonly used as the default hotkey to select a window/tab in terminal apps.
What about using RETURN to toggle between "input mode" and "emoji selection mode"?
@matchai , yeah, I agree CTRL +
Terminal Mouse Selection: LMB + CMD + C
"Toggle" Keyboard Selection:
Also, I 100% agree that the primary input method for a CLI tool should be the keyboard, but I have to think about where and how I typically use emojis. I almost never use emojis in terminal applications. 99.8% of the time, I am going to paste them into a text editor, a web browser, or a chat application...and for that, the primary input device is the mouse, so having the mouse able to copy the emoji seems like a built-in shortcut to me.
Personally, I think the idea of having both keyboard hotkeys and mouse-enabled interaction would be ideal. Each only involving a one or two-step process (i.e., 1 or 2 press events).
Namely:
If the process takes 3 or more press events to get the emoji into the clipboard, then it's not worth adding in, since right now its only a three-step (three-event) process to copy the emoji using the mouse and native OS copy-paste methods.
Throwing out another idea.
In the interactive prompt, you could press Enter
or Tab
to go into "arrow mode" like Yeoman does.
IE:
emoj 'i love unicorns'
+ Enter
Didn't even see this issue, but I already made a pull request for copying the emojis to your clipboard. It copies the emojis when you press enter.
I am really liking @zwacky 's idea of holding down the CTRL key, which activates "selection mode" (then the numbers could appear below the emoji keeping the UI nice and clean). As long as the CTRL key is held down, you can use the number keys to copy one, or multiple emojis to the clipboard. Releasing the CTRL key and pressing it again would start a new copy session. For those rare occasions where you would want all 7 emojis copied at once, perhaps a single key could be assigned for that. @noodlesftw has assigned the Return key to do just that in PR #8
I like @zwacky's idea too. Let's go with that.
@noodlesftw Would you be able to update your pull request?
For those rare occasions where you would want all 7 emojis copied at once
0
could mean all
?
0
could meanall
?
👍
@sindresorhus I'll update it tomorrow night, haven't got the time to work on it this weekend. I'll hold on to @zwacky's idea.
I've added a -c, --copy
flag for non-interactive mode. I haven't had time yet to implement the interactive part. PR still welcome for that :)
This is fixed in the latest version.
I'm thinking something like this (in the interactive prompt):
And you can use for example Ctrl+1 to copy the first emoji.
Need people's thoughts. Any way to better present / handle this? The goal is to quickly be able to find and get a relevant emoji.
Should also have a
-c, --copy
flag for non-interactive mode.