robert@notes: ~/posts — zsh
➜ robert@notes ~/posts git:(master) cat ~/.motd
Robert's notes - Notes on Go, Kubernetes, Terraform/OpenTofu, AWS and DevOps culture.
➜ robert@notes ~/posts git:(master) ls ~
➜ robert@notes ~/posts git:(master) glow add-timestamp-to-bash-history.md

Add timestamp to Bash history

bash

Sometimes there is a need to add a timestamp to bash history. At my work I found it quite useful, especially when some other developers have access to the same box or when you simply want to have an idea when a command from the history was executed.   This is how we can achieve this:

echo 'export HISTTIMEFORMAT="%d.%m.%y %T"' >> ~/.profile

(or .bash_profile if you use a RHEL based distro) and after that just re-login or reload your profile file. Time formatting is exactly the same as for strftime - please check man 3 strftime.

Hint: reloading the profile can be done like this: . .profile or source .profile

– Cheers Robert

➜ robert@notes ~/posts git:(master) cat FEEDBACK