Greenclips [1] works well for this if you're a rofi [2] user. You can set a staticHistoryPath that points to a file. When activating Greenclips, you can search for the desired command. I've been using this on my Linux box for the last year or so and haven't looked back.
[1] https://github.com/erebe/greenclip
[2] https://github.com/davatorium/rofi