https://github.com/vindarel/termp
Trivial utility: are we in a terminal window or in a dumb one? (like Emacs' Slime)
https://github.com/vindarel/termp
Last synced: 11 months ago
JSON representation
Trivial utility: are we in a terminal window or in a dumb one? (like Emacs' Slime)
- Host: GitHub
- URL: https://github.com/vindarel/termp
- Owner: vindarel
- Created: 2020-12-01T19:38:07.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-09-02T15:17:22.000Z (almost 2 years ago)
- Last Synced: 2025-04-05T22:29:07.068Z (about 1 year ago)
- Language: Common Lisp
- Size: 2.93 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Are we running inside a real or a dumb terminal window?
Adapt your logic for the terminal or for Slime.
A small utility that I use in [progressons](https://github.com/vindarel/progressons) and that I ~~might~~ re-use.
~~~lisp
(defvar *termp*) ; Unbound by default.
(defun termp (&key force)
"Return T if we run on a terminal.
This must fail on Slime (on Emacs' default shell prompt) and succeed on a Lisp in a terminal window."
(if (and (not force)
(boundp '*termp*))
*termp*
(setf *termp* (not (equalp "dumb" (uiop:getenv "TERM"))))))
~~~
There is also `termp:quit &optional code`: quit the Lisp image (`uiop:quit`) only if we are in a non-dumb terminal. Helps to test scripts.
---
## Installation
This library is on [Ultralisp](https://ultralisp.org/github).
## Licence
WTFPL