diff --git a/runtime/entrypoint.d/sttysize.sh b/runtime/entrypoint.d/sttysize.sh new file mode 100755 index 00000000..95e92202 --- /dev/null +++ b/runtime/entrypoint.d/sttysize.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +RC=${HOME}/.bashrc +SNIPPET=/st2-docker/entrypoint.d/sttysize.snippet + +if ! grep -q sttysize ${RC}; then + echo >> ${RC} + echo "[ -r ${SNIPPET} ] && . ${SNIPPET}" >> ${RC} +fi diff --git a/runtime/entrypoint.d/sttysize.snippet b/runtime/entrypoint.d/sttysize.snippet new file mode 100644 index 00000000..64161401 --- /dev/null +++ b/runtime/entrypoint.d/sttysize.snippet @@ -0,0 +1,17 @@ +# Ensure the entire terminal is used. This particular code comes from +# https://gist.github.com/scentoni/f4bda3a07cf7711125de3928f95809af + +res() { + + old=$(stty -g) + stty raw -echo min 0 time 5 + + printf '\033[18t' > /dev/tty + IFS=';t' read -r _ rows cols _ < /dev/tty + + stty "$old" + + stty cols "$cols" rows "$rows" +} + +res