diff options
author | Peter | 2024-05-31 16:39:10 +0100 |
---|---|---|
committer | Peter | 2024-05-31 16:39:10 +0100 |
commit | 59d67aeb8144436f0df3fcdc8abc9f2a5e86bfce (patch) | |
tree | b5a621e12fe1ee4e51818428307c6041150e46a5 /.local/bin | |
parent | 9e6ddd2d1ca3f420bed1f5233617ed686b1efd3d (diff) | |
download | dotfiles-59d67aeb8144436f0df3fcdc8abc9f2a5e86bfce.tar.gz dotfiles-59d67aeb8144436f0df3fcdc8abc9f2a5e86bfce.tar.bz2 dotfiles-59d67aeb8144436f0df3fcdc8abc9f2a5e86bfce.zip |
Add mileage script
Diffstat (limited to '.local/bin')
-rwxr-xr-x | .local/bin/milieage | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/.local/bin/milieage b/.local/bin/milieage new file mode 100755 index 0000000..c6831cd --- /dev/null +++ b/.local/bin/milieage @@ -0,0 +1,22 @@ +#!/bin/bash + +old_current=$(tail -1 "$0" | awk '{print $3}') +old_previous=$(tail -1 "$0" | awk '{print $4}') +old_miles=$(tail -1 "$0" | awk '{print $5}') + +read -rp "Enter current car odometer ($old_current): " current +if [ -z "${current}" ]; then current="$old_current"; fi +read -rp "Enter previous month odometer ($old_previous): " previous +if [ -z "${previous}" ]; then current="$old_previous"; fi +read -rp "Enter business miles for month ($old_miles): " miles +if [ -z "${miles}" ]; then current="$old_miles"; fi + +banked="$(echo "($miles + $previous) - $current" | bc)" +lie_miles="$(shuf -i 5-15 -n 1)" +lie="$(echo "$previous" + "$miles" + "$lie_miles" | bc)" +printf "\nYou have %s miles in the bank.\nEnter %s as your month end." "$banked" "$lie" + +datestamp=$(date +"%Y-%m-%dT%H:%M:%S%z") +printf "# %s %s %s %s %s" "$datestamp" "$current" "$previous" "$miles" "$banked">> "$0" + +exit |