summaryrefslogtreecommitdiff
path: root/personal/cv/add-personal-info.sh
blob: 2e9ea8b7eaf8dcd4fd9b46ac7f9b1266c2ba4452 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

set -eu

input=$1; output=$2
cp ${input} ${output}

. personal-info

fullname=$(getent passwd $(whoami) | cut -d: -f5 | cut -d, -f1)
sed -i s/INSERT-FULLNAME-HERE/"${fullname}"/ ${output}

# On the one hand, anyone can compute my age from my birth date.  On
# the other hand, wasting reader brain cycles on this computation
# sounds kind of rude.  On the gripping hand, having to bump my age
# manually every year would be silly.  Clearly the way forward is to
# summon the powers of bash, date, bc and sed to save us the trouble.

birthstamp=$(date -d "${birthday}" +%s)
now=$(date +%s)
age=$(bc <<< "(${now}-${birthstamp})/(3600*24*365.25)")
sed -i s/INSERT-BIRTHDATE-HERE/"${birthday} (${age})"/ ${output}

sed -i s/INSERT-LOCATION-HERE/"${location}"/ ${output}

sed -i s/INSERT-PHONE-HERE/"${phone_number}"/ ${output}

# Set by .profile and/or .xsessionrc.
sed -i s/INSERT-MAIL-HERE/${EMAIL}/ ${output}