35 lines
812 B
Plaintext
35 lines
812 B
Plaintext
test -e /etc/lsb-release && source /etc/lsb-release
|
|
|
|
function exec() {
|
|
echo -e "\e[36;1m[exec]\e[36;21m $*\e[0m"
|
|
# LOG=$(tempfile -p exec)
|
|
$@
|
|
# &>$LOG
|
|
EC=$?
|
|
if [ $EC -gt 0 ]; then
|
|
echo -e "\e[31;1m[warn]\e[31;21m Command completed with exitcode $EC\e[0m"
|
|
# tail -n5 $LOG | awk '{ print " " $0 }'
|
|
fi
|
|
# rm $LOG
|
|
}
|
|
function task() {
|
|
echo -e "\e[36;1m[exec]\e[36;21m $*\e[0m"
|
|
$@ > /dev/null & spinner
|
|
}
|
|
function info() {
|
|
echo -e "\e[32;1m[info]\e[32;21m $*\e[0m"
|
|
}
|
|
function spinner() {
|
|
local pid=$!
|
|
local delay=0.5
|
|
local spinstr='|/-\'
|
|
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
|
|
local temp=${spinstr#?}
|
|
printf "%c" $spinstr
|
|
local spinstr=$temp${spinstr%"$temp"}
|
|
sleep $delay
|
|
printf "\b"
|
|
done
|
|
printf " \b"
|
|
}
|