Views:
84,032β
Votes: 2β
Tags:
command-line
gnome-terminal
Link:
π See Original Answer on Ask Ubuntu β§ π
URL:
https://askubuntu.com/q/1164893
Title:
How to show a running clock in terminal before the command prompt
ID:
/2019/08/11/How-to-show-a-running-clock-in-terminal-before-the-command-prompt
Created:
August 11, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
If you never need to use debian_chroot
then itβs a handy place to put the time the command prompt was displayed by using:
export PROMPT_COMMAND='debian_chroot=$(date +%r)'
Type this in your terminal and watch your command prompt change with the time:
rick@alien:~$ export PROMPT_COMMAND='debian_chroot=$(date +%r)'
(09:14:59 PM)rick@alien:~$
After the time is set once, to get a running clock which updates every second use:
while sleep 1;do tput sc;tput cup $(($(tput lines)-1)) 1;printf `date +%r`;tput rc;done &
This .gif
shows the commands in action: