I recently successfully added timestamps to my terminal prompt: https://stackoverflow.com/questions/61335641/bash-zsh-terminal-prompt-time-date/61346774#61346774
But i soon realized that what I actually want is a timestamp appended to the beginning of each output line of my terminal. Is there a simple For/Do statement I can add to my .bashrc file such that for any command, do (for example PrintF) %Y-%m-%d %H:%M:%S (this would be added to each new line of output printed in the terminal)?
where this:
2020-04-21 09:04:50 [purr@purr-ms7998 ~]$ sudo pacman -Syyu
:: Synchronizing package databases...
core 172.0 KiB 272 KiB/s 00:01 [----------------------------------] 100%
extra 2016.1 KiB 470 KiB/s 00:04 [----------------------------------] 100%
community 5.9 MiB 265 KiB/s 00:23 [----------------------------------] 100%
multilib 192.9 KiB 157 KiB/s 00:01 [----------------------------------] 100%
:: Starting full system upgrade...
there is nothing to do
2020-04-21 09:05:44 [purr@purr-ms7998 ~]$
Would become this:
[2020-04-21 09:04:50] [purr@purr-ms7998 ~]$ sudo pacman -Syyu
[2020-04-21 09:04:50]:: Synchronizing package databases...
[2020-04-21 09:04:50] core 172.0 KiB 272 KiB/s 00:01 [----------------------------------] 100%
[2020-04-21 09:04:50] extra 2016.1 KiB 470 KiB/s 00:04 [----------------------------------] 100%
[2020-04-21 09:04:50] community 5.9 MiB 265 KiB/s 00:23 [----------------------------------] 100%
[2020-04-21 09:04:50] multilib 192.9 KiB 157 KiB/s 00:01 [----------------------------------] 100%
[2020-04-21 09:04:50]:: Starting full system upgrade...
[2020-04-21 09:04:50] there is nothing to do
[2020-04-21 09:05:44] [purr@purr-ms7998 ~]$
I am a complete beginner, so if a for/do statement could work for this purpose, please provide an example so that I can learn the correct syntax for what I'm trying to do.
I am currently using xfce4-terminal if that is of any use.
inxi:
System: Kernel: 5.6.5-3-MANJARO x86_64 bits: 64 compiler: gcc v: 9.3.0
parameters: BOOT_IMAGE=/boot/vmlinuz-5.6-x86_64
root=UUID=98f63e52-6a5d-422b-88d0-73642c6c3ee8 rw quiet apparmor=1 security=apparmor
udev.log_priority=3
Desktop: Xfce 4.14.2 tk: Gtk 3.24.13 info: xfce4-panel wm: xfwm4 dm: LightDM 1.30.0
Distro: Manjaro Linux
Info: Processes: 204 Uptime: 47m Memory: 15.53 GiB used: 5.30 GiB (34.1%) Init: systemd v: 244
Compilers: gcc: 9.3.0 Shell: bash v: 5.0.16 running in: xfce4-terminal inxi: 3.0.37