bash - PS1 can't have two "\$"? -
i want bash prompt string 1 have both date/time , return code of last command. so, thought do
ps1="\[\e[00;34;01m\]\$(date +'%a %b %e, %t')\[\e[35m\] \$?\[\e[00m\] >> "
which thought give me blue date (like thu jul 2, 01:01:01
) purple return code , >>
(given ansi escape sequences produce "normal" colors based on pallets terminals). however, doesn't work.
ps1="\$? >> "
and
ps1="\$(date +\"%a %b %e, %t\") >> "
both work, though, , when first way, first "\$"
gets interpreted , other gets interpreted when bashrc sourced. (so, "\$?"
gets evaluated 0
, stays 0
.)
any thoughts why happening?
note: have tried ps1='$(date +"%a %b %e, %t") $? >> '
can else replicate in unix bash? if so/if not, please leave comment.
i don't know why bash ignores second \$, try using \d format date:
ps1="\[\e[00;34;01m\]\d{%a %b %e, %t}\[\e[35m\] \$?\[\e[00m\] >> "
this works me under bash version 4.2.46
Comments
Post a Comment