#!/bin/bash # reads lines from stdin and displays the most recent # line in the terminal's first row and last columns. # # example usage: # while true; do date; sleep 1; done | ./top_right_indicator IFS='' AWIDTH=0 while read -r DISPLAY_STRING; do PWIDTH=$AWIDTH AWIDTH=${#DISPLAY_STRING} WIDTH=$(( PWIDTH > AWIDTH ? PWIDTH : AWIDTH )) TARGET_COLUMN=$(($(tput cols)-$WIDTH)) tput sc tput cup 0 $TARGET_COLUMN printf '%'"$WIDTH"'s' "$DISPLAY_STRING" tput rc done