short date in bash PS1 prompt

时光总嘲笑我的痴心妄想 提交于 2019-12-04 22:20:12

Try this:

PS1="\$(date +%d.%m.%Y) > "
export PS1

Try including \D{%d.%m.%Y}. You can use any time format suppoorted by strftime(3).

Use \D{format} where format is a strftime format code. For example:

$ export PS1='\D{%d.%m.%Y}$ '
08.02.2012$

Rather than telling the shell to execute the date command each time, you would rather use the built-in format. Hence you can also use (though a little variation from what you have asked)

\D{%F %T}

to give you date and time. date in format : YYYY-MM-DD and time in format hh:mm:ss.

marwansherin

you can try this that display time:

$ PS1="\n\t \u@\h:\w# "

08:18:57 user@localhost:/home/user#
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!