简体   繁体   中英

How can I get the “lein repl” history to work in cygwin?

I'm using Cygwin on Windows 7 and the latest lein, but when I am in the repl, pressing up and down moves me around the repl console instead of showing me history (which is what I expect). I've googled around and seen that this is related to using jline instead of readline (whatever that means) but I don't know how to use this information to fix my problem.

I found the answer here:

I modified the lein startup script to call stty and set jline.terminal, and it seems to work:

stty -icanon min 1 -echo
$LEIN_JAVA_CMD \
    -client -XX:+TieredCompilation \
    -Djline.terminal=jline.UnixTerminal \
    $LEIN_JVM_OPTS \
    -Dfile.encoding=UTF-8 \
    -Dmaven.wagon.http.ssl.easy=false \
    -Dleiningen.original.pwd="$ORIGINAL_PWD" \
    -Dleiningen.trampoline-file="$TRAMPOLINE_FILE" \
    -cp "$CLASSPATH" \
    clojure.main -m leiningen.core.main "$@"
EXIT_CODE=$?
stty icanon echo

I modified that section in the lein script and now up = history.

An alternative approach to the one you suggested would be to install rlwrap which is available in Cygwin. This will give you Readline capabilities (eg. command history search and navigation) to any interactive command line application. If you've used bash for any length of time you will know what these capabilities are.

You will need to start the applications as parameters to the readline wrapper but this can be hidden away using aliases or functions as appropriate:

rlwrap lein repl

The benefit of using rlwrap over your suggestion is that it can add this capabilities to more than just the specific case of the repl.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM