summaryrefslogtreecommitdiff
path: root/journal.sh
diff options
context:
space:
mode:
authorShav Kinderlehrer <[email protected]>2023-11-18 01:14:41 -0500
committerShav Kinderlehrer <[email protected]>2023-11-18 01:14:41 -0500
commitb0d5301b904d60d300a2b7ab2a93da28bb15049f (patch)
tree46805209e0fe23278f0f84d71a976183f1b54941 /journal.sh
parenteac4027d33d26d6fd10f6f6072a6d22a76ee6cc8 (diff)
downloadscripts-b0d5301b904d60d300a2b7ab2a93da28bb15049f.tar.gz
scripts-b0d5301b904d60d300a2b7ab2a93da28bb15049f.zip
Update journal.sh to use nix
Diffstat (limited to 'journal.sh')
-rwxr-xr-xjournal.sh25
1 files changed, 12 insertions, 13 deletions
diff --git a/journal.sh b/journal.sh
index 111370f..783dd6a 100755
--- a/journal.sh
+++ b/journal.sh
@@ -1,23 +1,23 @@
-#!/usr/bin/env zsh
+#!/usr/bin/env nix-shell
+#! nix-shell -i zsh
+#! -p zsh coreutils gpg
# ====
# journal.sh
# Manages a simple journaling system.
#
-# Written for Mac
-#
-# Uses GNU coreutils, gdate, gsed, etc.
+# Uses nix to manage all deps
# ====
set_dates() {
- nowtime=$(gdate "+%H:%M") || exit
- day=$(gdate "+%A" -d "$*") || exit
- daynum=$(gdate "+%e" -d "$*") || exit
- month=$(gdate "+%m" -d "$*") || exit
- year=$(gdate "+%Y" -d "$*") || exit
- date=$(gdate "+%Y-%m-%d" -d "$*") || exit
+ nowtime=$(date "+%H:%M") || exit
+ day=$(date "+%A" -d "$*") || exit
+ daynum=$(date "+%e" -d "$*") || exit
+ month=$(date "+%m" -d "$*") || exit
+ year=$(date "+%Y" -d "$*") || exit
+ date=$(date "+%Y-%m-%d" -d "$*") || exit
- date_path=$(gdate "+%Y/%m" -d "$*") || exit
+ date_path=$(date "+%Y/%m" -d "$*") || exit
journal_prefix=~/code/txt/cal
file="$journal_prefix/$date_path/$date.txt"
}
@@ -40,7 +40,6 @@ case "$arg" in
$PAGER "$file"
fi
-
exit 0
esac
@@ -53,7 +52,7 @@ if [ ! -f "$file" ]; then
printf "%0.s=" {1..13} >> $file
printf "\n" >> $file
- cal -h "$month" "$year" | gsed "0,/$daynum/{s//XX/}" >> $file
+ cal -h "$month" "$year" | sed "0,/$daynum/{s//XX/}" >> $file
truncate -s -1 $file
printf "\n$day\n" >> $file