LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-01-2011, 03:22 PM   #1
gangsta77
LQ Newbie
 
Registered: Feb 2011
Posts: 10

Rep: Reputation: 0
showing date on command prompt line?


ok i need to add the date of the root of the command prompt line, i can get it show to the date for any user

how do i just do it for root? and i added it to the .bash_profile file

export PS1='[`date +%D` \u@\h \W]\$ '
 
Old 03-01-2011, 04:05 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
This is my prompt setting from my .bashrc:
Code:
if [ "$UID" -eq "0" ]
then
   PS1="\[\033[31;1m\]\u \d] \\$\w\n \[\033[0m\]"
else
   PS1="\[\033[34;1m\]\u \d] \\$\w\n \[\033[0m\]"
fi
Comment out your PS1 line, and replace it with something like this. Just edit the second PS1 line to remove \d. Then the date will show only in the root users prompt.
This also shows the root prompt in red, and the user in blue.

Last edited by bigrigdriver; 03-02-2011 at 11:48 AM.
 
Old 03-01-2011, 04:11 PM   #3
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Just to add to that, have you ever tried out zsh? You can install and configure themes that have a lot more you can do with your prompt. If you want, I can post my .zshrc file later on when I get home from work.
 
Old 03-02-2011, 11:15 AM   #4
vonbiber
Member
 
Registered: Apr 2009
Distribution: slackware 14.1 64-bit, slackware 14.2 64-bit, SystemRescueCD
Posts: 533

Rep: Reputation: 129Reputation: 129
My prompt shows the current working directory in one line
and the date and time on the second, followed by '$ '
(or #, if on a root console)
The current working directory is shown in white on a green background
The date blue on white, time white on blue, then '$ ' back to normal
(white on black).
Code:
 ~ 
Wed Mar 02 18:13:08$ cat .bashrc 
PS1='\[\033[42m\033[37m\] \w \[\033[0m\]
\[\033[47m\033[34m\]\d \[\033[44m\033[37m\]\t\[\033[0m\]\$ '
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynebolic showing only command prompt rajanicinesoft Linux - Newbie 1 03-18-2010 06:54 PM
[SOLVED] command line not showing path wisdom Linux - Desktop 4 11-06-2009 02:00 PM
showing only directorys from the command line djgerbavore Linux - Newbie 7 07-13-2005 08:34 PM
what is the command prompt for showing device? yenonn Linux - General 9 02-21-2003 02:01 AM
Showing Distrobution in Command Line? dpaille Linux - General 12 11-24-2002 09:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration