GPaste icon indicating copy to clipboard operation
GPaste copied to clipboard

Method to replace text in clipboard?

Open amites opened this issue 7 years ago • 5 comments

First off thank you for this fine piece of software, I know it's not simple to maintain something like this for so long.

That said I'm curious if adding a way to replace text in the clipboard buffer exists or could be added? Dug through closed issues and couldn't find anything like it

the scenario is a commonly copied string of text that I need to replace part of to use elsewhere, would be nice if this happened automatically

happy to offer support where I can -- don't have much background with desktop software but been pushing code for a long time

amites avatar Feb 03 '17 00:02 amites

Hi, You can edit any element you want from your history, including the active one using the gui.

gpaste-client ui or hitting <Ctrl><Alt>G should spawn it.

Keruspe avatar Feb 03 '17 13:02 Keruspe

what I'm really looking for is a method to trigger the replacement

ie: if <pattern_match> then run <sed>

amites avatar Feb 07 '17 01:02 amites

For now you could do something like

gpaste-client replace 8 "$(gpaste-client get 8 | sed s/foo/bar/g)"

That should work to replace foo by bar in the 8th item

Keruspe avatar Feb 07 '17 06:02 Keruspe

cool, though doesn't cover my desired feature

given a pointer for where in the code base to add a hook would be appropriate I'm happy to work on a prototype (though may take a while)

amites avatar Feb 07 '17 16:02 amites

Oh, now I think I get it. You want for eample that every time there is "foobar" in what you copy, gpaste automatically transforms it into "waldo" and put the result in the clipboard? If so, the right place would probably be inside g_paste_history_add in src/libgpaste/core/gpaste-history.c No idea how to make it easily configurable though.

Keruspe avatar Feb 07 '17 16:02 Keruspe