]> arthur.barton.de Git - ax-zsh.git/blob - bin/axttyinfo
axttyinfo: Show COLORTERM when set
[ax-zsh.git] / bin / axttyinfo
1 #!/usr/bin/env zsh
2 #
3 # AX-ZSH: Alex' Modular ZSH Configuration
4 # Copyright (c) 2015-2017 Alexander Barton <alex@barton.de>
5 #
6
7 source "$AXZSH/core/11_terminal/11_terminal.zshrc" || exit 1
8
9 unset VERBOSE
10
11 while [[ $# -gt 0 ]]; do
12         case "$1" in
13                 "-v")
14                         VERBOSE=1
15                         ;;
16                 *)
17                         echo "Usage: ttyinfo [-v]" >&2
18                         exit 1
19         esac
20         shift
21 done
22
23 print -Pn -- "$fg[white]$FX[bold]$HOST$FX[no-bold] "
24 print -Pn -- "$fg[yellow]$(tty)$FX[reset], "
25 print -Pn -- "$fg[green]$FX[underline]${TERM:-?}$FX[reset] "
26 print -Pn -- "(${COLUMNS:-?}x${LINES:-?})"
27 print -Pn -- "$FX[reset]"
28 [[ -n "$LANG" ]] && print -Pn -- "; LANG=$LANG"
29 [[ -n "$COLORTERM" ]] && print -Pn -- "; COLORTERM=$COLORTERM"
30 echo
31
32 [[ -z "$VERBOSE" ]] && return 0
33
34 check_function_result() {
35         "$1"; r=$?
36         print -Pn -- " - $fg[white]$1$FX[reset]() = "
37         if [[ $r -eq 0 ]]; then
38                 print -P -- "$fg[green]yes$FX[reset]"
39         else
40                 print -P -- "$fg[red]NO$FX[reset]"
41         fi
42         return $r
43 }
44
45 echo
46 for f (
47         axzsh_is_dumb_terminal
48         axzsh_is_modern_terminal
49         axzsh_is_utf_terminal
50         axzsh_is_widechar_terminal
51 ); do
52         check_function_result "$f"
53 done
54 echo