aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions60
-rwxr-xr-xrc.sysinit3
2 files changed, 35 insertions, 28 deletions
diff --git a/functions b/functions
index d94a9ef..d0747ba 100644
--- a/functions
+++ b/functions
@@ -4,26 +4,40 @@
# width:
-STAT_COL=80
-if [[ ! -t 1 ]]; then
- USECOLOR=""
-elif [[ -t 0 ]]; then
- # stty will fail when stdin isn't a terminal
- STAT_COL="$(/bin/stty size)"
- # stty gives "rows cols"; strip the rows number, we just want columns
- STAT_COL="${STAT_COL##* }"
-elif /bin/tput cols &>/dev/null; then
- # is /usr/share/terminfo already mounted, and TERM recognized?
- STAT_COL=$(/bin/tput cols)
-fi
-if ((STAT_COL==0)); then
- # if output was 0 (serial console), set default width to 80
+calc_columns () {
STAT_COL=80
- USECOLOR=""
-fi
+ if [[ ! -t 1 ]]; then
+ USECOLOR=""
+ elif [[ -t 0 ]]; then
+ # stty will fail when stdin isn't a terminal
+ STAT_COL="$(/bin/stty size)"
+ # stty gives "rows cols"; strip the rows number, we just want columns
+ STAT_COL="${STAT_COL##* }"
+ elif /bin/tput cols &>/dev/null; then
+ # is /usr/share/terminfo already mounted, and TERM recognized?
+ STAT_COL=$(/bin/tput cols)
+ fi
+ if ((STAT_COL==0)); then
+ # if output was 0 (serial console), set default width to 80
+ STAT_COL=80
+ USECOLOR=""
+ fi
+
+ # we use 13 characters for our own stuff
+ STAT_COL=$(($STAT_COL - 13))
+
+ if [[ -t 1 ]]; then
+ SAVE_POSITION="\e[s"
+ RESTORE_POSITION="\e[u"
+ DEL_TEXT="\e[$(($STAT_COL+4))G"
+ else
+ SAVE_POSITION=""
+ RESTORE_POSITION=""
+ DEL_TEXT=""
+ fi
+}
-# we use 13 characters for our own stuff
-STAT_COL=$(($STAT_COL - 13))
+calc_columns
# disable colors on broken terminals
TERM_COLORS="$(/bin/tput colors 2>/dev/null)"
@@ -76,16 +90,6 @@ if [[ $USECOLOR =~ yes|YES ]]; then
fi
fi
-if [[ -t 1 ]]; then
- SAVE_POSITION="\e[s"
- RESTORE_POSITION="\e[u"
- DEL_TEXT="\e[$(($STAT_COL+4))G"
-else
- SAVE_POSITION=""
- RESTORE_POSITION=""
- DEL_TEXT=""
-fi
-
# prefixes:
PREFIX_REG="::"
diff --git a/rc.sysinit b/rc.sysinit
index 2158f4a..b5d63ea 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -95,6 +95,9 @@ unset mods
status "Waiting for UDev uevents to be processed" \
udevadm settle --timeout=${UDEV_TIMEOUT:-30}
+# in case loading a module changed the display mode
+calc_columns
+
run_hook sysinit_udevsettled
# bring up the loopback interface