Created
January 28, 2019 09:36
-
-
Save mbarkhau/e9003e190e75602762c8c0e4fbd6bbde to your computer and use it in GitHub Desktop.
Shell script that is similar to `watch -c`, but output is cleared.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
HOME=$(tput cup 0 0) | |
ED=$(tput ed) | |
EL=$(tput el) | |
printf '%s%s' "$HOME" "$ED" | |
while true | |
do | |
ROWS=$(tput lines) | |
COLS=$(tput cols) | |
CMD="$@" | |
${SHELL:=sh} -c "$CMD" | head -n $ROWS | while IFS= read LINE; do | |
printf '%-*.*s%s\n' $COLS $COLS "$LINE" "$EL" | |
done | |
printf '%s%s' "$ED" "$HOME" | |
sleep 1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment