tuned and readme
This commit is contained in:
parent
c47f722054
commit
e188045b45
11
README.md
11
README.md
|
@ -1,4 +1,13 @@
|
|||
birthdays
|
||||
=========
|
||||
|
||||
shellscript for printing upcoming birthdays
|
||||
shellscript for printing upcoming birthdays
|
||||
|
||||
in ~/birthdays:
|
||||
|
||||
between date (month/day) and message it is important to put a tabulator!
|
||||
|
||||
example:
|
||||
|
||||
1/1 happy new year!
|
||||
4/6 fred's birthday
|
|
@ -1,15 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
# path to file
|
||||
conf_file=$HOME/birthdays
|
||||
days_left=30
|
||||
|
||||
readarray lines < "$conf_file"
|
||||
|
||||
for i in "${lines[@]}"; do
|
||||
birthday=$(date -d "$( cut -f 1 <<< "$i" )" +%j 2>/dev/null | sed 's/^0*//')
|
||||
today=$(date +%j 2>/dev/null | sed 's/^0*//')
|
||||
days=$(( ${birthday} - ${today} ))
|
||||
days=$(( $(date -d "$( cut -f 1 <<< "$i" )" +%j 2>/dev/null | sed 's/^0*//') - $(date +%j 2>/dev/null | sed 's/^0*//') ))
|
||||
if [ 0 -le "$days" ] && [ "$days" -le "$days_left" ];then
|
||||
if [ "$days" -le $((days_left / 2)) ];then
|
||||
echo -e "\033[33m$( cut -f 2- <<< "$i" ) in $days days\033[m"
|
||||
|
@ -18,6 +15,5 @@ for i in "${lines[@]}"; do
|
|||
else
|
||||
echo -e "\033[32m$( cut -f 2- <<< "$i" ) in $days days\033[m"
|
||||
fi
|
||||
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue