Copy command from history to bash prompt

you need to take a look at the bash fc command.

If you want to edit before rexecuting a history line just do like this

fc 123

where 123 is the history line number you see typing the command history.
It will open your favorite editor and allow you to modifiy the line then quit and save and it will run.

You can also do it a range of command like this:

fc 123 135

To work on command history from 123 to 135.

Edit 1:
if you need to run without edit consider watch the post Re-execute fc command from history


If you want to reexecute a command from your history, you can use ^r (ctrl + r) in your terminal. It's a reverse search which permits to retrieve a command and edit it before you enter it. I don't know if it works with other shell than bash. Though it's like one of the most useful thing I ever seen.

From the bash documentation :

reverse-search-history (C-r)
Search backward starting at the current line and moving ‘up’ through the history as necessary. This is an incremental search.

Here is the manual.