title: Copy current command at bash prompt to clipboard
body: <p>I would like a quick keyboard command sequence to copy the current command at a bash prompt to the clipboard. </p>
  
  <p>So that, for example, to copy the last bash command to the clipboard, I'd press up+<code>[some command sequence]</code> to copy it. Or, for example, to search for a command in bash hisory, I'd use ctrl+r, search, display it on the command prompt, and then <code>[some command sequence]</code> to copy it, etc.</p>
  
  <p>My current solution is using bash pipes: <a href="https://stackoverflow.com/questions/749544/pipe-to-from-clipboard">Pipe to/from the clipboard</a></p>
  
  <p>So, to copy the previous command to clipboard:</p>
  
  <pre><code>echo "!!" | pbcopy
  </code></pre>
  
  <p>Which isn't too terrible, but what if the command to copy isn't the last command, etc.</p>
  
  <p>What's the proper way to achieve what I'm trying to achieve here?</p>