sindresorhus / emoj

Find relevant emoji from text on the command-line :open_mouth: :sparkles: :raised_hands: :horse: :boom: :see_no_evil:
MIT License
2.37k stars 58 forks source link

Add ability to easily copy an emoji #2

Closed sindresorhus closed 7 years ago

sindresorhus commented 8 years ago

I'm thinking something like this (in the interactive prompt):

› unicorns
🦄  🎠  🐴  🌈  🐎  ✨  🍓
 1   2   3   4   5   6   7

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.

huyhong commented 8 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

radiovisual commented 8 years ago

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.

sindresorhus commented 8 years ago

Yeah, I know how to implement it. That's easy :) Just looking for feedback on the UI and the interaction.

vhmth commented 8 years ago

+1

zwacky commented 8 years ago

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.

sindresorhus commented 8 years ago

@zwacky What if you could do for example Ctrl+1, Ctrl+2 to copy multiple.

zwacky commented 8 years ago

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.

sindresorhus commented 8 years ago

@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.

lukeed commented 8 years ago

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.

matchai commented 8 years ago

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

lukeed commented 8 years ago

@matchai Or a number(s) followed by native copy.

1, 2, 5, CMD+C

vhmth commented 8 years ago

I like @matchai's approach. That's good UX. You have a confirmation/guiding UI.

radiovisual commented 8 years ago

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.

radiovisual commented 8 years ago

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.

matchai commented 8 years ago

@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"?

radiovisual commented 8 years ago

@matchai , yeah, I agree CTRL + might be too common. As for the toggle switch, I think it could work for users who want to use the keyboard as the primary input, because it equals the same number of press events that can be used right now to select a single emoji character with the mouse:

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:

  1. With Mouse: Single-Click (or Double-Click) on the emoji to get it into the clipboard for users who intend to paste the emoji into a browser, editor or chat application, and,
  2. With Keyboard: Offer a hotkey combo to allow a quick-copy of the emoji into the clipboard

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.

brock commented 8 years ago

Throwing out another idea.

In the interactive prompt, you could press Enter or Tab to go into "arrow mode" like Yeoman does.

yo

IE: emoj 'i love unicorns' + Enter

spaksa commented 8 years ago

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.

radiovisual commented 8 years ago

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

sindresorhus commented 8 years ago

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?

radiovisual commented 8 years ago

0 could mean all?

👍

spaksa commented 8 years ago

@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.

sindresorhus commented 7 years ago

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 :)

sindresorhus commented 7 years ago

This is fixed in the latest version.