> > Dear all,
> > Recently I have a idea to display a real time clock at
> > the right bottom conner of my screen. (just like win95
> > little clock).
> If you update this every second, you may find that the screen will
> flicker too much for it to be in any way useful. I'd go for only
> updating it every minute.
> > my idea is that, I can use `date` to form a while loop and
> > every time it display at the same line.
> > The Question is:
> > How can I control the output at the same location every
> > time and not affect other fount ground program?
> > I am using Linux and bash.
> man tput
> e.g. to place the cursor at position row 3 column 4, do:
> tput cup 3 4
> Cheers,
> Dave :-)
Printing ansi control chars also can work. I know with these
ansi control chars, you can save and restore your cursor position.
this is nice to goto the postion, change the date, and return the
cursor to the origional position so the user doesn't get messed
up with the cursor jumping around. Below is an example of the
single echo that could do the whole thing. The \033 is the octal
representation of the ESC key.
echo "\033[s\033[24;50H$(date)\033[u\c"
Save move to print restore
curs row 24 date curs
col 50
Here is a simple script to show it working.
#!/bin/ksh
echo Hello
printf "Prompt Location: "
for i in 1 2 3 4
do
echo "\033[s\033[20;50H$(date)\033[u\c"
sleep 1
done
echo "STILL AT PROMPT"
# END KSH
- Matt