telling function how to print line at cursor position in terminal
print_in_top_right () {
local columns=$(tput cols) # get the terminal width
local text=${1:0:$columns} # truncate the text to fit on a line if needed
tput sc # Save the Cursor position
tput cup 0 $((columns - ${#text})) # move the CUrsor Position to the top line, with just enough space for $text on the right
printf %s "$text"
tput rc # Restore the Cursor position saved by sc
}