Bash provides an environment variable called PROMPT_COMMAND. The contents of this variable are executed as a regular Bash command just before Bash displays a prompt. .:: paste.toolforge.org ::. .:: my.bio ::. .:: podcasts.apple.com ::. [Z shell Modules] .:: sala.ggyy.tw ::.
[21:55:01][giles@nikola:~] PS1="[\u@\h:\w]\$ " [giles@nikola:~] PROMPT_COMMAND="date +%H%M" 2155 [giles@nikola:~] d bin mail 2156 [giles@nikola:~] |
What happened above was that I changed PS1 to no longer include the .:: substance3d.adobe.com ::. .:: telegra.ph ::. .:: learn.cipmikejachapter.org ::. .:: addons.mozilla.org ::. \t escape sequence (added in a previous section), so the time was no longer a part of the prompt. Then I used .:: www.demilked.com ::. .:: telegra.ph ::. .:: telegra.ph ::. [Developer Guide: Deep learning] .:: www.crossroadsbaitandtackle.com ::. .:: w88manucom.livejournal.com ::. .:: forum.dmec.vn ::. date +%H%M to display the time in a format I like better. But it appears on a different line than the prompt. Tidying this up using .:: backloggery.com ::. .:: vivavegasluck.co.uk ::. .:: antspride.com ::. .:: podcasts.apple.com ::. .:: telegra.ph ::. .:: groups.google.com ::. .:: coolors.co ::. echo -n ... as shown below works with Bash 2.0+, but appears not to work with Bash 1.14.7: apparently the prompt is drawn in a different way, and the following method results in overlapping text. .:: podcasts.apple.com ::. .:: podcasts.apple.com ::. .:: ro.pinterest.com ::. .:: ncnews.co ::. .:: md.darmstadt.ccc.de ::. .:: docs.google.com ::. .:: supportnet.de ::. .:: podcasts.apple.com ::. .:: www.mobafire.com ::. .:: podcasts.apple.com ::. .:: telegra.ph ::.
2156 [giles@nikola:~] PROMPT_COMMAND="echo -n [$(date +%H%M)]" [2156][giles@nikola:~]$ [2156][giles@nikola:~]$ d bin mail [2157][giles@nikola:~]$ unset PROMPT_COMMAND [giles@nikola:~] |
echo -n ... controls the output of the date command and suppresses the trailing newline, allowing the prompt to appear all on one line. At the end, I used the .:: onne.link ::. .:: kumu.io ::. .:: gesoten.com ::. .:: s3.us-east-2.amazonaws.com ::. .:: quicknote.io ::. .:: www.tarsheedad.com ::. unset command to remove the PROMPT_COMMAND environment variable.