diff --git a/board/common/rootfs/bin/help b/board/common/rootfs/bin/help index cd673618..2296fedd 100755 --- a/board/common/rootfs/bin/help +++ b/board/common/rootfs/bin/help @@ -1,41 +1,72 @@ #!/bin/sh -H1=$(printf '\033[7m') -H2=$(printf '\033[1m') -DM=$(printf '\033[2m') -UL=$(printf '\033[4m') -IT=$(printf '\033[3m') -BL=$(printf '\033[5m') -H0=$(printf '\033[0m') +# COLUMS and ROWS should be set on the console, if not, use fallback +if [ -z "$COLUMNS" ]; then + if command -v tput; then + COLUMNS=$(tput cols) + else + COLUMNS=80 + fi +fi -noansi() +h1() { - H1="" - H2="" - DM="" - UL="" - IT="" - BL="" - H0="" + STR="$*" + if [ -n "$plain" ]; then + echo "$STR" | tr '[:lower:]' '[:upper:]' + echo "$STR" | sed 's/./=/g' + else + printf "\033[7m%-${COLUMNS}s\033[0m" "$STR" + fi +} + +h2() +{ + STR="$*" + if [ -n "$plain" ]; then + echo "$STR" + echo "$STR" | sed 's/./-/g' + else + printf "\033[1m%-${COLUMNS}s\033[0m" "$STR" + fi +} + +ul() +{ + if [ -n "$plain" ]; then + echo "__${*}__" + else + printf "\033[54%s\033[0m" "$*" + fi +} + +em() +{ + if [ -n "$plain" ]; then + echo "**${*}**" + else + printf "\033[5m%s\033[0m" "$*" + fi } overview() { cat <. This is equivalent to M-. -${H2}Navigation${H0} +$(h2 "Navigation") Though arrow keys, Home/End, and PgUp/PgDn usually work, using Mg over serial console can sometimes cause these keys to be mismapped by terminal program. @@ -214,7 +244,7 @@ console can sometimes cause these keys to be mismapped by terminal program. M-> Move to end of file C-x g Move to line number -${H2}Editing${H0} +$(h2 "Editing") All edit commands that kill (cut) text is placed in a kill ring (clipboard). Note: when marking text, there is no visual mark. @@ -236,7 +266,7 @@ Note: when marking text, there is no visual mark. C-d Delete character to the right C-o Open new line at cursor -${H2}General Commands${H0} +$(h2 "General Commands") C-g Abort current command C-l Recenter buffer on current line @@ -252,7 +282,7 @@ ${H2}General Commands${H0} C-x b Switch to another buffer C-x C-c Exit -${H2}Window Commands${H0} +$(h2 "Window Commands") C-x 0 Unsplit, keep other window C-x 1 Unsplit, keep this window @@ -278,12 +308,11 @@ editor() vi emacs cat < master br0 state UP ${UL}group port${H0} + 4: e0: master br0 state UP $(em "group port") link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff ... @@ -583,7 +611,7 @@ Another way is to add something like this to /etc/rc.local: done -${H2}Interesting Files${H0} +$(h2 "Interesting Files") - /etc/dhcpcd.conf General DHCP and ZeroConf (LL) settings - /etc/network/interfaces The original, useful for small setups @@ -593,8 +621,7 @@ ${H2}Interesting Files${H0} - /etc/sysctl.d/* Snippets, useful for per-subsystem settings -${H1}Summary ${H0} - +$(h1 "Summary") All persistent networking is set up in /etc/network/interfaces using the program ifupdown-ng. The tools to reconfigure networking at runtime are: @@ -612,7 +639,7 @@ adding VLANs, the vlan1 and vlan2 interfaces on top so it of it all. Then finally it can start the DHCP client on vlan1 and set the static IP address on vlan2. - ${BL}>>> Be careful with these tools when logged in remotely! <<<${H0} + $(em ">>> Be careful with these tools when logged in remotely! <<<") EOF } @@ -639,7 +666,7 @@ topic() if [ "$1" = "-p" ]; then shift pager="cat" - noansi + plain="yes" else if command -v most; then pager=most