Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Key-binding to copy highlighted command to system clipboard #226

Open
arijit-hal opened this issue Jan 14, 2022 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@arijit-hal
Copy link

Hi,
Is there a way to add a keybinding to copy a highlighted command from mcfly's heads-up display directly to the system clipboard? Presently, the only way I can achieve this consistently across several terminal emulators (kitty, gnome-terminal etc.) is by using the edit option (pressing TAB) and then copying the result into the emulator's internal buffer (using Ctrl+U).
Thanks!

@cantino cantino added enhancement New feature or request help wanted Extra attention is needed labels Jan 14, 2022
@cantino
Copy link
Owner

cantino commented Jan 14, 2022

That's a nice feature idea, thanks @arijit-hal

@navazjm
Copy link
Contributor

navazjm commented Jan 31, 2022

I would like to claim this one and try to figure it out.

What is the preferred end of action for this command? For example, after the user press the keybinding to copy the selected text, should the user stay in McFly or exit out?

@arijit-hal
Copy link
Author

Ah nice follow up question! It would probably be preferable to stay within McFly after the selected content has been copied to the clipboard. This way once the user has pasted the copied content into their desired application, they can initiate another search and repeat the process if needed.

@cantino
Copy link
Owner

cantino commented Jan 31, 2022

That makes sense.

@navazjm
Copy link
Contributor

navazjm commented Jan 31, 2022

That's what I was thinking. On top of that, say the user copies the wrong command. It would be annoying to restart the application and then find the desired command again. I know I would find that annoying.

@navazjm
Copy link
Contributor

navazjm commented Feb 1, 2022

For the keybindings, I am thinking of using 'yy' if the user is using vim mode, since in vim that will copy the whole line. I am not an emacs user but an article I read says to use Ctrl+k to copy a line. However, Ctrl+k already has a keybinding. Any recommendations for keybindings for emacs? Or any keybinding recommendations to keep it the same for both emacs and vim?

@arijit-hal
Copy link
Author

I agree with the choice of 'yy' in vim mode. In the "usual" bash-like mode Ctrl+k should have been a good choice as it is the default for cutting a typed command in the bash shell from cursor till the end. If that does not work, I suggest Ctrl+i kind of hybrid between vim and Ctrl+k and short for "insert" into clipboard buffer or Ctrl+y if that can be used while inside McFly. Alternatively, setting custom keybindings through environment variables could also be another option.

@navazjm
Copy link
Contributor

navazjm commented Feb 2, 2022

@cantino after doing some research, there is no clear way on copying text to clipboard using Rust's std lib. However, there is a crate that implements this functionality. How would you feel about using it?

Repo link: https://github.com/aweinstock314/rust-clipboard

@arijit-hal
Copy link
Author

arijit-hal commented Feb 2, 2022

Seems like a reasonable crate. But, given the lack of sufficient knowledge about rust-crates I would like to get @cantino 's opinion.

@cantino
Copy link
Owner

cantino commented Feb 2, 2022

Given its use in Mozilla Servo, I'm comfortable adding it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants