Is there anyway to change the bash prompt to automatically update say when the time changes to reflect the time. So instead of something like it being 11:30
and the pressing enter 3 minutes later it then says 11:33
it would instead continuously update that prompt every minute to reflect the current time.
Asked
Active
Viewed 657 times
4

csteifel
- 2,854
- 6
- 35
- 61
-
3Not really. The prompt is simply printed to standard error, then `bash` waits until a command is executed to print the prompt again. – chepner Nov 08 '13 at 22:24
-
2Sorry, but... no. The current bash version can only send the prompt once per read, and doesn't come back later to update a prompt it already emitted. Your best bet would be to implement this at the terminal emulator level. For example, I think GNU screen has a configuration setting for that. – JB. Nov 08 '13 at 22:27
-
I assume that there aren't really any other shell's that will allow me to do that either? Zsh or anything of the sort? – csteifel Nov 08 '13 at 22:48
-
Most probably not, since, as others said, you need an emulator/or_something to capture the output and process it continuously, updating the time each and every second. You may be interested, as @JB. said, in using `GNU screen`, or `tmux` -- the later is a considerably *improved* version of `screen`. – Rubens Nov 09 '13 at 00:13
-
1I have a clock in my `tmux` status bar, which does update continuously. Keep in mind, however, your terminal emulator will interpret that as screen activity, if you use such a monitoring feature. – chepner Nov 09 '13 at 16:09
-
1@legion See http://stackoverflow.com/questions/2187829/constantly-updated-clock-in-zsh-prompt for doing it in zsh. – philh Dec 10 '13 at 11:22