📅  最后修改于: 2022-03-11 14:55:53.027000             🧑  作者: Mango
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
}