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
4 Answers
I am not sure tu understand, try adding
date "+%_m %Y" | xargs cal
date +%T
at the end of .bashrc
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
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')"
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\]"
export PS1='\D{%Y/%m/%d} \t[\w/]\$ '
in.bashrc
: this will show the date and time with your current directory, as in2014/12/28 11:10:43[~/]$
. (I don't see the point of usingxargs
as suggested in the other answers.)