1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-05 03:29:02 -08:00
rc/sh/monitor

15 lines
291 B
Text
Raw Normal View History

2013-10-21 01:04:45 -07:00
#!/bin/zsh
monitor() {
local time=$1
2013-10-21 01:36:13 -07:00
local cmd=$2
2013-10-21 01:04:45 -07:00
local stop=0
trap stop=1 INT
2013-10-26 02:55:05 -07:00
echo -en "\e[H\e[2J"
2013-10-21 01:04:45 -07:00
while [ $stop -eq 0 ]; do
2013-10-26 02:55:05 -07:00
echo -en "\e[1J\e[H"
$cmd 2>&1 | fold -w $COLUMNS | tail -$((LINES-1))
2013-10-21 01:04:45 -07:00
sleep $time || break
done
}
2013-10-21 01:36:13 -07:00
monitor $1 $2