title: Search inside ipython history
body: <p><a href="http://ipython.scipy.org/moin/" rel="noreferrer">ipython</a>'s <code>%his</code> command outputs recent commands entered by the user. Is it possible to search within these commands? Something like this:</p>
  
  <pre><code>[c for c in %history if c.startswith('plot')]
  </code></pre>
  
  <p><strong>EDIT</strong> I am not looking for a way to rerun a command, but to locate it in the history list. Of course, sometimes I will want to rerun a command after locating it, either verbatim or with modifications.</p>
  
  <p><strong>EDIT</strong> searching with <code>ctr-r</code> and then typing <code>plot</code> gives the most recent command that starts with "plot". It won't list all the commands that start with it. Neither can you search within the middle or the end of the commands</p>
  
  <h2>Solution</h2>
  
  <p>Expanding PreludeAndFugue's solution here what I was looking for:</p>
  
  <pre><code>[l for l in  _ih if l.startswith('plot')]
  </code></pre>
  
  <p>here, the <code>if</code> condition can be substituted by a regex</p>