16

I am using Java 8 build 1.8.0-b132 on OSX 10.9.2.

I am playing with Nashorn the new JavaScript runtime in Java 8.

I am using Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/jjs but unfortunately jjs is pretty unusable in interactive mode since cursor left/right does not work:

jjs
jjs> var x =^[[D

The above output (^[[D) is the result of pressing 'cursor left'. Is there a way to fix that behavior and using cursor left/right in the jjs console?

jbandi
  • 17,499
  • 9
  • 69
  • 81
  • 2
    you may find related things [here](http://stackoverflow.com/search?q=%22^[[D%22), for example: http://stackoverflow.com/questions/14489635/how-to-move-the-cursor-in-sml-njs-repl-in-terminal-on-mac – assylias Mar 11 '14 at 00:26
  • if you want to access nashorn from a console from web http://lorenzoongithub.github.io/nudge4j/ – Zo72 Mar 16 '17 at 20:46

1 Answers1

21

Thanks to @assylias for pointing me to rlwrap.

I installed rlwrap via homebrew:

brew install rlwrap

Then I defined an alias in my .zshrc (would be the same for bash in .bashrc)

alias jjs='rlwrap /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home/bin/jjs'

Now I can use jjs on the commandline and the <- and -> keys are working as expected.

assylias
  • 321,522
  • 82
  • 660
  • 783
jbandi
  • 17,499
  • 9
  • 69
  • 81