mirror of
https://github.com/gaschz/dotfiles.git
synced 2025-03-01 14:22:33 +01:00
fix: option to disable resize of dumb consoles
Relevant when using "xl console".
This commit is contained in:
parent
f705616ed4
commit
7e2502b70a
@ -9,12 +9,16 @@
|
|||||||
## Resize terminal columns and lines to current window size.
|
## Resize terminal columns and lines to current window size.
|
||||||
## Useful for terminals over link (serial console, socat's pty etc).
|
## Useful for terminals over link (serial console, socat's pty etc).
|
||||||
|
|
||||||
test -t 0 || exit
|
if test -n "${TERM_RESIZE_DISABLE:-}"; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
test -t 0 || exit 0
|
||||||
|
|
||||||
## If argument is provided, allow user to bypass tty check.
|
## If argument is provided, allow user to bypass tty check.
|
||||||
if test "${#}" -eq 0; then
|
if test "${#}" -eq 0; then
|
||||||
## Shells on graphical sessions (terminal emulators) are skipped.
|
## Shells on graphical sessions (terminal emulators) are skipped.
|
||||||
test "${XDG_SESSION_TYPE:-}" = "tty" || exit
|
test "${XDG_SESSION_TYPE:-}" = "tty" || exit 0
|
||||||
## Serial ports and devices are desired.
|
## Serial ports and devices are desired.
|
||||||
term_file="$(tty)"
|
term_file="$(tty)"
|
||||||
term_file_wanted="ttyUSB ttyS"
|
term_file_wanted="ttyUSB ttyS"
|
||||||
@ -35,7 +39,7 @@ if test "${#}" -eq 0; then
|
|||||||
## Terminal can handle screen resizing by itself.
|
## Terminal can handle screen resizing by itself.
|
||||||
if test "${term_file_active}" = "0"; then
|
if test "${term_file_active}" = "0"; then
|
||||||
unset term_file_active
|
unset term_file_active
|
||||||
exit
|
exit 0
|
||||||
fi
|
fi
|
||||||
unset term_file_active
|
unset term_file_active
|
||||||
fi
|
fi
|
||||||
@ -47,7 +51,7 @@ if ! echo R | read -r -t 1 -sd R 2>/dev/null; then
|
|||||||
if has resize; then
|
if has resize; then
|
||||||
resize_cmd="$(resize)"
|
resize_cmd="$(resize)"
|
||||||
eval "${resize_cmd}" >/dev/null
|
eval "${resize_cmd}" >/dev/null
|
||||||
exit
|
exit 0
|
||||||
fi
|
fi
|
||||||
## Slow due to heavy stty calls.
|
## Slow due to heavy stty calls.
|
||||||
termios="$(stty -g)"
|
termios="$(stty -g)"
|
||||||
@ -56,7 +60,7 @@ if ! echo R | read -r -t 1 -sd R 2>/dev/null; then
|
|||||||
IFS='[;R' read -r _ rows cols _ </dev/tty
|
IFS='[;R' read -r _ rows cols _ </dev/tty
|
||||||
stty "${termios}" cols "${cols}" rows "${rows}"
|
stty "${termios}" cols "${cols}" rows "${rows}"
|
||||||
unset termios
|
unset termios
|
||||||
exit
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Non-POSIX compliant and fast.
|
## Non-POSIX compliant and fast.
|
||||||
@ -73,11 +77,11 @@ IFS='[;R' read -r -t 1 -s -d R _ rows cols _ </dev/tty || {
|
|||||||
if test "${COLUMNS}" = "${cols}" && test "${LINES}" = "${rows}";then
|
if test "${COLUMNS}" = "${cols}" && test "${LINES}" = "${rows}";then
|
||||||
stty echo
|
stty echo
|
||||||
unset rows cols
|
unset rows cols
|
||||||
exit
|
exit 0
|
||||||
elif test "${rows}" -gt 0 && test "${cols}" -gt 0;then
|
elif test "${rows}" -gt 0 && test "${cols}" -gt 0;then
|
||||||
stty echo cols "${cols}" rows "${rows}"
|
stty echo cols "${cols}" rows "${rows}"
|
||||||
unset rows cols
|
unset rows cols
|
||||||
exit
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "error: cannot resize screen: unsupported terminal emulator" >&2
|
echo "error: cannot resize screen: unsupported terminal emulator" >&2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user