mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
Add screen clearing routine and improve commands display
This commit is contained in:
27
packages/bsp/common/etc/update-motd.d/00-clear
Executable file
27
packages/bsp/common/etc/update-motd.d/00-clear
Executable file
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: https://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="clear"
|
||||
MOTD_DISABLE=""
|
||||
|
||||
[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd
|
||||
|
||||
for f in $MOTD_DISABLE; do
|
||||
[[ $f == $THIS_SCRIPT ]] && exit 0
|
||||
done
|
||||
|
||||
# Clear screen
|
||||
if [ -f /bin/bash ]; then
|
||||
export TERM="$(/bin/bash -c 'echo $TERM')"
|
||||
fi
|
||||
clear
|
||||
|
||||
exit 0
|
||||
@@ -215,4 +215,4 @@ if [[ $(command -v zpool) ]]; then
|
||||
line=$((line+1))
|
||||
fi
|
||||
fi
|
||||
if [[ $line -ne 0 ]]; then echo ""; fi
|
||||
echo ""
|
||||
|
||||
@@ -19,12 +19,13 @@ for f in $MOTD_DISABLE; do
|
||||
done
|
||||
|
||||
list=(
|
||||
"System config ","sudo ","armbian-config"
|
||||
"System monitor ","","htop"
|
||||
"System config","sudo ","armbian-config"
|
||||
"System monitor","","htop"
|
||||
)
|
||||
|
||||
# verify if command exits on the system
|
||||
cmd_count=0
|
||||
name_len=0
|
||||
output=()
|
||||
for l in "${list[@]}"
|
||||
do
|
||||
@@ -33,6 +34,10 @@ do
|
||||
command=$(echo $l | cut -d"," -f3)
|
||||
if command -v $command &> /dev/null
|
||||
then
|
||||
# seek for maximum description lenght
|
||||
if [ ${#name} -ge $name_len ]; then
|
||||
name_len=${#name}
|
||||
fi
|
||||
cmd_count=$(( cmd_count +1 ))
|
||||
output+=("${name},${sudo},${command}")
|
||||
fi
|
||||
@@ -40,15 +45,14 @@ done
|
||||
|
||||
# show list for existing command only
|
||||
if [[ "${cmd_count}" -gt 0 ]]; then
|
||||
|
||||
printf "\e[0;90m Commands: \x1B[0m\n" #; printf '%.s─' $(seq 1 39); echo -e "\x1B[0m"
|
||||
echo ""
|
||||
for l in "${output[@]}"
|
||||
do
|
||||
name=$(echo $l | cut -d"," -f1)
|
||||
sudo=$(echo $l | cut -d"," -f2)
|
||||
command=$(echo $l | cut -d"," -f3)
|
||||
printf " \e[1;33m%-26s\e[0m %-0s: $sudo$command\n" "$name"
|
||||
name=$(echo $l | cut -d"," -f1)
|
||||
sudo=$(echo $l | cut -d"," -f2)
|
||||
command=$(echo $l | cut -d"," -f3)
|
||||
printf " \e[1;33m%-${name_len}s\e[0m %-0s: $sudo$command\n" "$name"
|
||||
done
|
||||
echo -e "\033[0m"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user