Reputation: 16165
When I execute command line (linux) I want to know what time there were executed when I scroll up my terminal window. I saw this once setup in linux environment but how to do that?
Upvotes: 2
Views: 8184
Reputation: 31
1) Open bashrc file
gedit ~\.bashrc
2) Find the following text:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] :\[\033[01;34m\]\w\[\033[00m\]\$ '
3) And replace with:
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\] [\d|\t]:\[\033[01;34m\]\w\[\033[00m\]\$ '
4) Restart terminal to check.
Upvotes: 3
Reputation: 121
If you would love to show it in the below format:
YYYY-MM-DD HH:MM:SS {domain}@{userId}:~/{folder1}/{folder2}$
export PS1='\D{%F %T} \$\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$'
Upvotes: 2
Reputation: 1
Right now I have my terminal with this configuration:
[hh:mm:ss] PC@User:~$
This can be achieved putting the following instruction on file ~/.bashrc
export PS1="[\$(date +%k:%M:%S)] [\e]0;\u@\h: \w\a]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
I hope it works for you.
Upvotes: 0
Reputation: 785058
You can setup PS1
to always show current time in BASH;
export PS1='\A-\w>'
\A
- current time stamp without seconds part\t
- current time stamp with seconds\w
- current directoryUpvotes: 5
Reputation: 77095
You need to set your prompt variable (PS1
). Something like the following should get you going:
<~/temp>$ export PS1="[\$(date +%k:%M)]> "
[12:16]>
Upvotes: 7