quick-setup.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/bin/sh
  2. LSERVER_HOME="${LSERVER_HOME:-$HOME/.lserver}"
  3. command_dir="$LSERVER_HOME/commands"
  4. mkdir -p "$LSERVER_HOME"
  5. cat << EOF >> "$LSERVER_HOME/lserverrc.lisp"
  6. (in-package #:lserver)
  7. (defun file-command (function &optional description)
  8. (add-command (pathname-name *load-truename*) function description))
  9. (defparameter *path* (list (merge-pathnames #p"commands/*.lisp" (lserver-homedir-pathname))))
  10. (defun commands-from-path ()
  11. (dolist (glob *path*)
  12. (dolist (pathname (directory glob))
  13. (with-standard-io-syntax
  14. (let ((*package* (find-package "LSERVER")))
  15. (load pathname))))))
  16. (commands-from-path)
  17. EOF
  18. mkdir -p "$command_dir"
  19. cat << EOF > "$command_dir/eval.lisp"
  20. ;;;; eval.lisp
  21. (in-package #:lserver)
  22. (file-command (lambda (args)
  23. (dolist (arg args t)
  24. (eval (with-standard-io-syntax
  25. (let ((*package* (find-package "LSERVER")))
  26. (read-from-string arg))))))
  27. "Evaluate arguments as Lisp forms.")
  28. EOF
  29. cat << EOF > "$command_dir/say.lisp"
  30. ;;;; say.lisp
  31. (in-package #:lserver)
  32. (file-command (lambda (args)
  33. (loop for value in (multiple-value-list (eval (with-standard-io-syntax
  34. (let ((*package* (find-package "LSERVER")))
  35. (read-from-string (first args))))))
  36. do (format t "~A~%" value)
  37. finally (finish-output) (return t)))
  38. "Evaluate the argument as a Lisp form and print the values on separate lines.")
  39. EOF