LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   how to show the current time at the top in the current shell Always ? (https://www.linuxquestions.org/questions/linux-general-1/how-to-show-the-current-time-at-the-top-in-the-current-shell-always-4175500817/)

rohitchauhan 04-07-2014 01:47 AM

how to show the current time at the top in the current shell Always ?
 
Hi,
i am just trying something fun.

I want the current time to be displayed on the top of my screen ALWAYS...

I made changes in my .bashrc file like this:

Code:

# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
        . /home/rc/time
fi

The /home/rc/time file has the script which shows current time.

so when I log into the user i get the time on my screen but for only once.

But I want the time to be displayed on my screen all the time.

How can i achieve it ?

pan64 04-07-2014 01:58 AM

you need to execute that script time by time. that will eat up a lot of resources. What do you mean by always? (in every second, every minute or ??)

TenTenths 04-07-2014 04:41 AM

Why not change your prompt to show it:

Code:

PS1="[\d \t \u@\h:\w ] $ "

Habitual 04-07-2014 09:20 AM

Code:

while sleep 1;do tput sc;tput cup 0 $(($(tput cols)-75));date;tput rc;done &

rohitchauhan 04-09-2014 12:32 AM

@pan64:
I found my solution from TenTenths and habitual.

@TenTenths:
Thank you for your reply.

@habitual:
That solution totally worked for me.
Now i will just spend some time to understand that.

Thanks again to all !!!

Habitual 04-09-2014 03:05 PM

Glad it worked out.


All times are GMT -5. The time now is 03:26 AM.