Created
November 14, 2011 22:52
-
-
Save mjf/1365484 to your computer and use it in GitHub Desktop.
XTerm (256-colours) "pulsing" date in the top right corner of the terminal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Pulsing date XTerm mastery | |
# Copyright (C) 2011 Matous J. Fialka, <http://mjf.cz/> | |
# Released under the terms of The MIT License | |
# Prerequisities: flock tput TERM=xterm-256color | |
lock() | |
{ | |
while ! flock -w 1 1 2>/dev/null | |
do | |
: | |
done | |
} | |
unlock() | |
{ | |
while ! flock -w 1 -u 1 2>/dev/null | |
do | |
: | |
done | |
} | |
trap unlock SIGHUP SIGINT SIGQUIT SIGTERM | |
while : | |
do | |
for C in 17 18 19 20 21 21 20 19 18 17 # this seq. may vary | |
do | |
D=`date +%T` | |
X=$((`tput cols`-9)) | |
lock | |
echo -n -e "\e7\e[0;${X}H\e[37;0m\e[48;5;${C}m $D \e8\e[0m" | |
unlock | |
sleep 0.1 | |
done | |
done & |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is just little hack for fun and to show one of my friends how to lock standard output in order to do such silly things. Try it like this:
Note that the colour seq. may vary from environment to environment. Just choose values you like... Enjoy!