(osx version) when copied to ~/.bashrc or ~/.bash_profile, will create 'Ctrl + ]' keyboard shortcut, allowing current (not necessarily last) terminal command to be copied to the gui clipboard via pbpaste.
#!/bin/bash
bind '"\C-]":"\C-e\C-u pbcopy <<"EOF"\n\C-y\nEOF\n"'
# i might try:
# $ echo 'bind \'"\C-]":"\C-e\C-u pbcopy <<"EOF"\n\C-y\nEOF\n"\'' >> ~/.bash_profile