Skip to content

Instantly share code, notes, and snippets.

@aerique
Created February 18, 2021 12:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aerique/d461924307631fafd13c087fc8979bea to your computer and use it in GitHub Desktop.
Save aerique/d461924307631fafd13c087fc8979bea to your computer and use it in GitHub Desktop.
Use the Python Rich library from Common Lisp.
#!/usr/bin/env -S sbcl --script
;;;; Assumes the Python Rich library has been installed.
;;;; - https://github.com/willmcgugan/rich#rich
;;;;
;;;; To install (and assuming no Python experience):
;;;; - `python3 -m venv venv`
;;;; - `bash`
;;;; - `source venv/bin/activate`
;;;; - `pip install --upgrade pip`
;;;; - `pip install rich`
;;;;
;;;; Afterwards you can delete the `venv` directory and your system will be
;;;; as before.
;;;;
;;;; Also assumes Quicklisp is installed in its default location.
#-quicklisp
(let ((quicklisp-init (merge-pathnames "quicklisp/setup.lisp"
(user-homedir-pathname))))
(when (probe-file quicklisp-init)
(load quicklisp-init)))
(ql:quickload :py4cl :silent t)
(py4cl:import-module "rich")
(py4cl:import-module "rich.__main__")
(py4cl:import-module "rich.console")
;(rich:print (rich.__main__:make_test_card))
;; We need to force terminal colors.
(py4cl:python-method (rich.console:console :force_terminal t)
:print (rich.__main__:make_test_card))
;(rich:inspect (rich.console:console))
@aerique
Copy link
Author

aerique commented Feb 18, 2021

Using .sh as extension is pretty dumb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment