Java 8 Nashorn: Console pretty unusable - java-8

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?

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.

Related

Jedi-vim: No auto-complete on dot (.), testing shows erroneous "no python" error

I just installed jedi-vim and supertab (because I already had something bound to <C-Space>). <Tab> now shows the autocomplete menu and it's working pretty well, however I don't see any menus when I hit ..
If I use <Tab> in insert mode after pressing ., I get the normal menu that doesn't have the context of the name preceding the dot (and it's not at all useful because of it).
:verbose imap . says No mapping found, but I'm guessing that's not how jedi-vim works.
In my effort to troubleshoot the issue I've disabled my other plugins and replaced my .vimrc with just execute pathogen#infect().
Now, when I :e foo.py I see: "Error: jedi-vim failed to initialize Python: jedi-vim requires Vim with support for Python 2 or 3." I didn't get this error before, and :version shows that I have both Python 2 and 3 support.
Scriptnames: https://gist.github.com/hovissimo/a2413d6a5d0e1be356c0
:version: https://gist.github.com/hovissimo/f5a0e630edac8756397e
Edit:
:JediDebugInfo says Using Python Version: null
I don't know why I didn't see the error before, but it looks like my python3 integration in Vim was in fact broken.
I had Python 3.5 32-bit installed, but I was using a 64-bit version of Vim. Installing a 32-bit version of Vim (making sure it was compiled for python35) seems to have fixed all problems.

SBCL REPL use up arrow keys to show history

I have installed SBCL onto OSX through Macports.
When inside the REPL, it would be very convenient to be able to use ↑ and ↓ to iterate through the previous commands (similar to the behavior in bash or Python's REPL).
Is there a way to enable this functionality?
Install rlwrap and then run rlwrap sbcl.
You can get rlwrap through macports or homebrew.
It's pretty much as simple as that.
You could also also use Linedit. This is SBCL REPL specific, so it causes problems in other environments (like SLIME).
Or, you can try the SBCL-Readline project. Not sure how this works in SLIME, haven't tried it personally.
Both Uses UFFI to implement the use of C libraries.
Just make sure to skim through the source code and change the paths to libraries etc for your system, before trying them out!

Can't call history search in pry

I want to use reverse-i-search in Pry, but somehow I can't use in my OS X machine running iTerm2.
When I connect to VPS and run pry, then I can use the history search by pressing Ctrl + R.
It looks like the problem is located in my local environments, but I don't know what's wrong. I don't have a ~/.pryrc config file.
What can I do to find out the cause of problem?
This is libedit library problem (which replaces readline in modern MacOS distros.)
You need to explicitely configure libedit. Add to your ~/.editrc this line:
bind "^R" em-inc-search-prev
For other issues see man editrc.

iPython won't autoindent

I've never had this problem before and I don't understand why it's happening now so I'm hoping someone has encountered this. If I'm using iPython in interactive mode and try to do a loop I don't get an auto indent (and can't add one in on my own). So if I do
for i in range(5):
The next line is not indented, and if I try to indent it won't move the cursor over. I'm using iPython 0.13.2 on Mac OS X Mountain Lion
EDIT I can space over to add indentation but I can't use tab and it's never added automatically. I have also ensured that %autoindent has auto indent on
This is another symptom of the problems with libedit, the Mac equivalent of readline.
IPython will show a warning about libedit, which will instruct you to easy_install readline. Be sure to use easy_install, not pip - the latter won't install it correctly in this case.

Can you use R terminal commands on a Mac computer?

I wrote some code in school to basically bring up different graphs from R and I had wanted to use it on a Mac computer.
Is there are way to use R terminal commands on a Mac computer and is there a place where I could get more information about these Mac R Terminal commands?
I use the "R" command with the standard R.app GUI download, and would recommend using that instead of macports. After running the installer, I see:
$ which R
/usr/local/bin/R
$ ls -l /usr/local/bin/R
lrwxr-xr-x 1 root wheel 47 Nov 12 2008 /usr/local/bin/R -> /Library/Frameworks/R.framework/Resources/bin/R
$ R
R version 2.8.0 (2008-10-20)
...
>
I actually prefer to use this rather than the GUI, because it uses the current working directory for the workspace and history files (.Rhistory and .RData). It makes it easier to organize projects in this way by filesystem directory, and is very natural if you're using the commandline for other tasks as well (like running data preprocessing scripts).
Also, the terminal version lets you more easily cancel an expensive computation by pressing Ctrl-C. The GUI sometimes locks up during these.
By default, I think Mac terminal R uses the X11 display system, which isn't as good as the Quartz one used by the GUI. You can change this though: get the CarbonEL package, then put the following into your ~/.Rprofile:
goquartz = function() {
library("CarbonEL")
options(device='quartz')
Sys.unsetenv("DISPLAY")
}
if (.Platform$GUI == "X11") {
# this means we're running in the terminal (not GUI) version.
# if you actually want the X11 display, comment out the following line
goquartz()
}
You can use the R command-line tools if you install R for Mac OS X. The R website has disk images with installers, or you can install via MacPorts, like this:
$ sudo port install R
The R website has a slightly later version (2.9.1) than MacPorts (which is at 2.8.1).

Resources