Skip to content

Instantly share code, notes, and snippets.

@lostsh
Last active May 7, 2024 13:21
Show Gist options
  • Save lostsh/46a2fc3d74ec82256e51ca0c30fe2fd2 to your computer and use it in GitHub Desktop.
Save lostsh/46a2fc3d74ec82256e51ca0c30fe2fd2 to your computer and use it in GitHub Desktop.
[ARCHIVED] Display current datetime in french condensed format.
COL="\033[0;31m"
RST="\033[0m"
numbers=(\
"\n ██████╗ \n██╔═████╗\n██║██╔██║\n████╔╝██║\n╚██████╔╝\n ╚═════╝ \n" \
"\n ██╗ \n ███║ \n ╚██║ \n ██║ \n ██║ \n ╚═╝ \n" \
"\n██████╗ \n╚════██╗ \n █████╔╝ \n██╔═══╝ \n███████╗ \n╚══════╝ \n" \
"\n██████╗ \n╚════██╗ \n █████╔╝ \n ╚═══██╗ \n██████╔╝ \n╚═════╝ \n" \
"\n██╗ ██╗ \n██║ ██║ \n███████║ \n╚════██║ \n ██║ \n ╚═╝ \n" \
"\n███████╗ \n██╔════╝ \n███████╗ \n╚════██║ \n███████║ \n╚══════╝ \n" \
"\n ██████╗ \n██╔════╝ \n███████╗ \n██╔═══██╗\n╚██████╔╝\n ╚═════╝ \n" \
"\n███████╗ \n╚════██║ \n ██╔╝ \n ██╔╝ \n ██║ \n ╚═╝ \n" \
"\n █████╗ \n██╔══██╗ \n╚█████╔╝ \n██╔══██╗ \n╚█████╔╝ \n ╚════╝ \n" \
"\n █████╗ \n██╔══██╗ \n╚██████║ \n ╚═══██║ \n █████╔╝ \n ╚════╝ \n")
chars=(\
"\n ██╗ \n ██╔╝ \n ██╔╝ \n ██╔╝ \n ██╔╝ \n ╚═╝ \n" \
"\n \n ██╗ \n ╚═╝ \n ██╗ \n ╚═╝ \n \n" \
"\n \n \n \n \n \n \n")
show_datetime () {
let size=$(echo "$1" | wc -c)-1
#boder top
echo -ne "$COL ╔"; for c in $(seq 1 $(($size*9 + 2))); do echo -ne "═"; done; echo "╗";
for i in $(seq 1 6); do # six is the height of a char
echo -ne " ║ $RST"
for j in $(seq 1 $size); do
num=$(echo $1 | cut -c $j)
case $num in
"/") echo -n "$( echo "${chars[0]}" | cut -d'n' -f$(($i+1)) | sed -e 's/\\//g')" ;;
":") echo -n "$( echo "${chars[1]}" | cut -d'n' -f$(($i+1)) | sed -e 's/\\//g')" ;;
" ") echo -n "$( echo "${chars[2]}" | cut -d'n' -f$(($i+1)) | sed -e 's/\\//g')" ;;
*) echo -n "$( echo "${numbers[$num]}" | cut -d'n' -f$(($i+1)) | sed -e 's/\\//g')";;
esac
done
echo -e " $COL║"
done
#boder bottom
echo -n " ╚"; for c in $(seq 1 $(($size*9 + 2))); do echo -ne "═"; done; echo -e "╝$RST";
}
show_datetime "$(date +%d/%m\ %H:%M)"
@lostsh
Copy link
Author

lostsh commented Oct 29, 2021

while (true); do ./datetime.sh; sleep 60; clear; done;

clock

@lostsh
Copy link
Author

lostsh commented Mar 25, 2022

while true; do clear; show_datetime "$(date +%H:%M:%S)"; sleep 2; done;

clock

@lostsh
Copy link
Author

lostsh commented Mar 25, 2022

Customize .bashrc

To add the date and time when your console launches, you can add the date display function to your bashrc. To do this you just need to:

  1. add the function from the snippet above at the end of the .bashrc file
  2. add the following line at the end :
show_datetime "$(date +%d/%m\ %H:%M)"

Now you can enjoy 👍

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment