Add a handy SBCL rlwrap wrapper
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 25 Mar 2016 21:35:32 +0000 |
parents |
ab4a7458c22c
|
children |
153e4af91684
|
branches/tags |
(none) |
files |
bin/lisp bin/regen-sbcl-completions bin/rlwrap-sbcl |
Changes
--- a/bin/lisp Fri Mar 25 21:34:05 2016 +0000
+++ b/bin/lisp Fri Mar 25 21:35:32 2016 +0000
@@ -2,4 +2,4 @@
set -e
-rlwrap sbcl "$@"
+rlwrap-sbcl "$@"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/regen-sbcl-completions Fri Mar 25 21:35:32 2016 +0000
@@ -0,0 +1,21 @@
+#!/usr/bin/env sbcl --script
+(let (symbols)
+ (do-all-symbols (sym)
+ (let ((package (symbol-package sym)))
+ (cond
+ ((not (fboundp sym)))
+ ((or (eql #.(find-package :cl) package)
+ (eql #.(find-package :cl-user) package))
+ (pushnew (symbol-name sym) symbols))
+ ((eql #.(find-package :keyword) package)
+ (pushnew (concatenate 'string ":" (symbol-name sym)) symbols))
+ (package
+ (pushnew (concatenate 'string (package-name package)
+ ":"
+ (symbol-name sym))
+ symbols)))))
+ (with-open-file (output #.(concatenate 'string (posix-getenv "HOME")
+ "/.sbcl_completions")
+ :direction :output :if-exists :overwrite
+ :if-does-not-exist :create)
+ (format output "~{~(~A~)~%~}" (sort symbols #'string<))))
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/rlwrap-sbcl Fri Mar 25 21:35:32 2016 +0000
@@ -0,0 +1,13 @@
+#!/bin/sh
+BREAK_CHARS="(){}[],^%$#@\"\";''|\\"
+RLWRAP=
+if [ $TERM == "dumb" ]; then # slime
+ RLWRAP=
+else
+ RLWRAP="rlwrap --remember --history-filename=$HOME/.sbcl_history --histsize=1000000 -c -b $BREAK_CHARS -f $HOME/.sbcl_completions"
+fi
+if [ $# -eq 0 ]; then
+ exec $RLWRAP sbcl
+else # permits #!/usr/bin/env sbcl , but breaks sbcl --help, etc.
+ exec sbcl --script $*
+fi