title: Rails console issues using JRuby: no prompt character, no tab completion, broken arrow keys, etc
body: <p>I'm having various issues with my Rails console under JRuby, including</p>
  
  <ul>
  <li>No prompt character</li>
  <li><kbd>Tab</kbd> completion not working (literal tab gets inserted)</li>
  <li>Up/down arrows not browsing history (<code>^[[A</code> or <code>^[[B</code> gets inserted, respectively)</li>
  <li>Left/right arrows not moving cursor (<code>^[[D</code> or <code>^[[C</code> gets inserted, respectively)</li>
  <li><kbd>Home</kbd>/<kbd>End</kbd> keys not moving cursor to beginning/end of line (instead <code>1~</code> or <code>4~</code> inserted, respectively); <kbd>Ctrl</kbd>+<kbd>a</kbd> / <kbd>Ctrl</kbd>+<kbd>e</kbd> work though</li>
  <li><kbd>Ctrl</kbd>+<kbd>c</kbd> killing console instead of killing the line I'm entering</li>
  <li><kbd>Ctrl</kbd>+<kbd>d</kbd> not having any effect until I hit <kbd>Enter</kbd> (which then executes anything I entered between <kbd>Ctrl</kbd>+<kbd>d</kbd> and <kbd>Enter</kbd> in my Unix shell).</li>
  </ul>
  
  <p>I installed my JRuby interpreter from rvm like so:</p>
  
  <pre><code>rvm install jruby-1.6.8 --1.9
  </code></pre>
  
  <p>My Rails project is managed using Bundler (not rvm gemsets), so I run my Rails console using <code>bundle exec rails c</code>.  Interestingly, raw <code>irb</code> as well as <code>bundle exec irb</code> don't have most of the above issues, except the <kbd>Home</kbd>/<kbd>End</kbd> keys and <kbd>Ctrl</kbd>+<kbd>c</kbd> needs an <kbd>Enter</kbd> before I get a fresh prompt line.</p>
  
  <p>I can replicate the issue with a barebones Rails <code>Gemfile</code>:</p>
  
  <pre><code>source 'https://rubygems.org'
  gem 'rails', '3.2.6'
  gem 'sqlite3'
  </code></pre>
  
  <p>My shell is <code>zsh</code>, on Ubuntu 12.04 64-bit. <code>$JAVA_HOME</code> is <code>/usr/lib/jvm/java-7-openjdk-amd64</code>, but it might have still been java-6 when I installed this interpreter, if that matters.</p>
  
  <p><strong>Update: Some fixes</strong></p>
  
  <p>The missing prompt character is apparently caused by the <code>IRB.conf[:PROMPT_MODE]</code> getting set to <code>:NULL</code> by the Rails console.  For regular <code>irb</code>, mine gets set to <code>:RVM</code> (apparently rvm does this in <code>~/.rvm/scripts/irb.rb</code>; I ruled out rvm causing this issue by commenting out the script).  Providing a <code>:PROMPT_MODE</code> value in <code>~/.irbrc</code> fixes this.  I thought maybe a similar issue was causing the <kbd>Ctrl</kbd>+<kbd>c</kbd> / <kbd>Ctrl</kbd>+<kbd>d</kbd> problems by changing <code>:IGNORE_SIGINT</code> and <code>:IGNORE_EOF</code>, but they are both set to their default values.</p>
  
  <p>Tab completion and arrow keys get fixed by setting <code>:USE_READLINE</code> to true.</p>
  
  <p>Here's my current <code>~/.irbrc</code> that seems to fix said issues:</p>
  
  <pre><code>require 'irb/completion'
  
  IRB.conf[:PROMPT_MODE]  = :SIMPLE
  IRB.conf[:USE_READLINE] = true
  IRB.conf[:AUTO_INDENT]  = true
  </code></pre>