Currently there are 2 options to get code from History. You can send it to console or source. It would be great if you could copy it to the clipboard, both using the standard command/ctrl-C or with a button for the gui inclined. There is no way to copy it to the clipboard currently.
Feature Request: Add "To Clipboard" option for history viewer and allow copying with keyboard shortcuts
There's already an issue covering this:
You can help out by voting (with an emoji reaction) or commenting to add any more information about your use case that you think might be helpful.