laktak / extrakto

extrakto for tmux - quickly select, copy/insert/complete text without a mouse
MIT License
878 stars 45 forks source link

One key to both insert and copy #91

Closed psych3r closed 2 years ago

psych3r commented 2 years ago

It'd be nice to have the ability to have one key do both inserting and copying.

Assigning extrakto_copy_key and extracto_insert_key to the same key doesn't work.

The easiest solution imo is to add extrakto_copy_insert_key that does both copying and inserting.

Let me know if you're not opposed to the idea, I'd happily submit a pr...

laktak commented 2 years ago

Great idea but I think it we can support this by just passing the $trigger_pane to the copy tool.

If you want to try a PR, add the parameter:

        case "$key" in
            "${copy_key}")
                copy "$text" $trigger_pane

and update the copy function to pass the $trigger_pane to the @extrakto_clip_tool.

You can then configure your own script to first copy to the clipboard and then paste (see tmux paste-buffer -p -t $trigger_pane).

psych3r commented 2 years ago

I think it's best to preserve the current functionality. Users can copy text without polluting their command line. And they can insert text without polluting their clipboard.

I thought about checking whether both keys are the same: extrakto_copy_key == extracto_insert_key before doing something along the lines of your suggestion. But I don't think it's wise to lose the ability of only performing one of the two actions.

I think adding a new option to do both copying and inserting offers the most flexibility imo.

What do you think about that?

laktak commented 2 years ago

I don't think that this is a common use case that needs to have its own option.

When I need this I just copy first and then insert - which normally is just one additional keypress.

My suggestion was not to change anything for the current users but only to enable this for your setup.