title: How to write code to autocomplete words and sentences?
body: <p>I'd like to write code that does autocompletion in the Linux terminal. The code should work as follows.</p>
  <p>It has a list of strings (e.g. &quot;hello, &quot;hi&quot;, &quot;how are you&quot;, &quot;goodbye&quot;, &quot;great&quot;, ...).</p>
  <p>In the terminal, the user will start typing and when there is some match possibility, he gets the hint for possible strings, from which he can choose (similarly as in <a href="http://ruturajv.files.wordpress.com/2006/12/vim-7-php-autocomplete.png" rel="noreferrer">vim editor</a> or <a href="http://en.wikipedia.org/wiki/Incremental_search" rel="noreferrer">google incremental search</a>).</p>
  <p>e.g. he starts typing &quot;h&quot;, and he gets the hint</p>
  <p>h&quot;ello&quot;</p>
  <p>_ &quot;i&quot;</p>
  <p>_&quot;ow are you&quot;</p>
  <p>And better yet would be if it would complete words not only from the beginning, but from an arbitrary part of the string.</p>