Thursday, April 25, 2024
 Popular · Latest · Hot · Upcoming
103
rated 0 times [  103] [ 0]  / answers: 1 / hits: 120736  / 3 Years ago, sat, may 15, 2021, 8:31:28

I was wondering if it was possible to add timestamps to terminal prompts, and if so, how could I achieve this?


More From » bash

 Answers
5

Add this line to the ~/.bashrc file:



export PROMPT_COMMAND="echo -n [$(date +%H:%M:%S)] "


So the output will be something like:



[07:00:31] user@name:~$

[#35298] Sunday, May 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rtbrbab

Total Points: 461
Total Questions: 126
Total Answers: 117

Location: Saudi Arabia
Member since Fri, Jul 1, 2022
2 Years ago
rtbrbab questions
Fri, May 5, 23, 14:22, 1 Year ago
Tue, Nov 16, 21, 14:41, 2 Years ago
Thu, Mar 23, 23, 20:47, 1 Year ago
Sat, Jun 18, 22, 21:36, 2 Years ago
;