clipmenu icon indicating copy to clipboard operation
clipmenu copied to clipboard

clipdel: Delete current clip

Open brunelli opened this issue 6 years ago • 17 comments

I'd like to have a feature in clipdel to delete the current clip (first item of clipmenu), so I wrote a WIP patch which deletes the current clip and sets the clipboard content to the next item. It currently works with clipdel -l.

I'm opening this issue so we can discuss what's the best way to implement this feature.

brunelli avatar Jan 08 '19 22:01 brunelli

While i think the use case is valid, i think it would make more sense to create a "Delete picker" (with dmenu) as described in #57 since that would offer almost the same functionality.

GladOSkar avatar Jan 10 '19 15:01 GladOSkar

Not really, since I wouldn't be able to delete the last clip by just invoking a shortcut combo.

The issue gave me some ideas to implement this together with a clipdelmenu, though. I'll try to hack something when I get some time to spare.

brunelli avatar Jan 10 '19 17:01 brunelli

Yeah i guess ideally you could pass a number as a parameter for which item to delete and if no parameter is passed it asks interactively.

For the interactive mode one could even (for rofi users) use rofi's multi-select.

GladOSkar avatar Jan 10 '19 22:01 GladOSkar

Yeah i guess ideally you could pass a number as a parameter for which item to delete and if no parameter is passed it asks interactively.

I'm not sure about that, as there's no indication of which number corresponds to an entry.

For the interactive mode one could even (for rofi users) use rofi's multi-select.

Yeap, that'll totally be possible.

brunelli avatar Jan 10 '19 23:01 brunelli

I'm not sure about that, as there's no indication of which number corresponds to an entry.

Well i would say in the order of the history: 1 being the last item copied, 2 the one before that etc.

GladOSkar avatar Jan 11 '19 00:01 GladOSkar

Well i would say in the order of the history: 1 being the last item copied, 2 the one before that etc.

Sure, but what's the use case?

The only way to know a entry's position is by running clip{,del}menu interactively, and even there there's no way to tell what's the associated number without counting.

brunelli avatar Jan 11 '19 00:01 brunelli

I only thought of your use case: deleting the last element

GladOSkar avatar Jan 11 '19 00:01 GladOSkar

I was actually thinking of implementing it like clipdel --current.

But don't get me wrong, I'm all in for something like clipdel --entries 1 3-6, but I'm not sure that would be useful with the way clipmenu works.

@cdown have you thought of adding numbers in front of the entries in clipmenu?

Something like:

------------------------------------------------------
| clipmenu:                                          |
------------------------------------------------------
| [1] First entry                                    |
| [2] Second entry                                   |
| [3] A very very very very long entry... (12 lines) |
| [4] Lorem ipsum                                    |
| [5] Dolor sit amet                                 |
------------------------------------------------------

brunelli avatar Jan 11 '19 00:01 brunelli

I guess you're right, i don't really see a reason to automate deleting any other but the last copied entry

GladOSkar avatar Jan 11 '19 09:01 GladOSkar

I use something like this in the clipmenu script when I start it with a flag but I agree is not necessary.

rm_line=$(cut -d' ' -f2- "$cache_file" | grep -Fxn "$chosen_line"  | cut -d':' -f1 | sed 's/$/d/' | paste -sd';')
sed -i "${rm_line}" "$cache_file"
rm -f "$file"

ertwro avatar Apr 25 '20 03:04 ertwro

I guess you're right, i don't really see a reason to automate deleting any other but the last copied entry

Passwords, copied to clipboard on a timeout (for example, pass defaults to 45s) - you might copy something else in that time; the password manager wants to delete a known value, wherever it appears in order.

Edit - sorry, nevermind, I misread and there already is a clipdel, with exactly ^ that (and more general, with regex) behaviour.

OJFord avatar May 20 '20 23:05 OJFord

@cdown bumping this up since I too use pass with clipmenu, and don't want my password lingering in the clipboard. Would you accept a PR for this?

snprajwal avatar Jan 05 '24 19:01 snprajwal