1834149 Members
2158 Online
110064 Solutions
New Discussion

how to pass date to PS1

 
Hunki
Super Advisor

how to pass date to PS1

I want to display date in my PS1
PS1="$LOGNAME:"`uname -n`:'$PWD
>>'

PS1="$LOGNAME:"`uname -n`:'$PWD
--date here--
>>'
3 REPLIES 3
John Dvorchak
Honored Contributor

Re: how to pass date to PS1

try this

export DATE=`date`
PS1="$LOGNAME:"`uname -n`:'$PWD
${DATE}
>>'
If it has wheels or a skirt, you can't afford it.
Victor Fridyev
Honored Contributor

Re: how to pass date to PS1

Hi

You can add something like that:
$(date +%d/%m-%H:%M)
where you need the date. but take into account that you have to take care of date output renew after each enter/CR.
The best way to do this is to create an alias for the command cd.

HTH
Entities are not to be multiplied beyond necessity - RTFM
Hunki
Super Advisor

Re: how to pass date to PS1

Thanks John it worked.