Hello, I use #Guile #Scheme implementation, and I'd like to know how do you do to get the terminal width (to store in a variable for example)?
After tried with getenv procedure:
(getenv "COLUMNS")
That return #f (unless export COLUMNS=$(tput cols) either in .bashrc or in the guile shebang's script)
#!/usr/bin/env sh
exec env COLUMNS=$(tput cols) guile -s "$0"
!#
But using this, if you resize the terminal, the value is not updated.
So I have to use:
```
(use-modules (ice-9 popen))
(use-modules (ice-9 rdelim))
(define (get-terminal-width)
(let* ([port (open-input-pipe "tput cols")]
[terminal-width (read-line port)])
(close-pipe port)
terminal-width))
May be someone has a more efficient way to get the terminal width, thanks.
#GNUser #Guile #lisp #Scheme #programming
3 Comments
1 Shares