Update journal.sh to use nix
This commit is contained in:
parent
eac4027d33
commit
b0d5301b90
25
journal.sh
25
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
|
||||
|
Loading…
Reference in New Issue
Block a user