0

Is there a way to concatenate time after command has been entered? Example:

user@machine$ date
11:50:41
Tue Jun 25 11:50:41 EEST 2019

Current workaround is to add \t\n to PS1 before the username but that is not quite what I want to achieve, as it might lie, especially when the processing takes time and has a lot of output, e.g. when apt is run after a hiatus.

One idea I had was to capture the input with read but execute it after the time was printed. One downside is the command is then entered/printed second time.

krg
  • 117

1 Answers1

0
trap 'date +%T' DEBUG

Solution taken from answers to this question: Does bash have a hook that is run before executing a command?.