0

Yes, I am new to Ubuntu 12.04, and I would like to know if there is any way that I can get it to where my calendar and time shows up whenever I open up the terminal

1
  • 1
    In addition to suspectus' answer, you can also output the date and time on every prompt by setting export PS1='\D{%Y/%m/%d} \t[\w/]\$ ' in .bashrc: this will show the date and time with your current directory, as in 2014/12/28 11:10:43[~/]$ . (I don't see the point of using xargs as suggested in the other answers.)
    – AFH
    Dec 28, 2014 at 11:24

4 Answers 4

0

I am not sure tu understand, try adding

  date "+%_m %Y" | xargs cal
  date +%T

at the end of .bashrc

0

As you are new to Ubuntu, so I'm describing the process of editing the bashrc file as well.

To edit .bashrc file, you have to enter below command.

vi ~/.bashrc

or

nano ~/.bashrc

Then to end of the file and paste the lines

date "+%_m %Y" | xargs cal
date +%T

Save the file and quit and rerun the terminal. You will get output like below.

December 2014      
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30 31           

16:17:48
0

The commands cal and date can be used to output this information. cal with no arguments outputs the current month's calendar. Insert the commands in the ~/.bashrc (i.e. the .bashrc file in your HOME directory) so that each time a terminal opens the calendar and time are shown.

cal
echo "Time is $(date '+%T')"
0

You had good answers already, I will add my PS1 variable that shows the time in my prompt (you have to hit enter to get the actual time):

PS1="[\[\e[00;37m\]\A] \[\e[0m\]\[\e[01;33m\]\u\[\e[0m\]\[\e[00;37m\]@\[\e[0m\]\[\e[00;31m\]\h\[\e[0m\]\[\e[00;37m\] [\[\e[0m\]\[\e[00;36m\]\w\[\e[0m\]\[\e[00;37m\]] : \[\e[0m\]\[\e[00;33m\]\$\[\e[0m\]\[\e[00;37m\] \[\e[0m\]"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .