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
|
# journal.sh
|
||||||
# Manages a simple journaling system.
|
# Manages a simple journaling system.
|
||||||
#
|
#
|
||||||
# Written for Mac
|
# Uses nix to manage all deps
|
||||||
#
|
|
||||||
# Uses GNU coreutils, gdate, gsed, etc.
|
|
||||||
# ====
|
# ====
|
||||||
|
|
||||||
set_dates() {
|
set_dates() {
|
||||||
nowtime=$(gdate "+%H:%M") || exit
|
nowtime=$(date "+%H:%M") || exit
|
||||||
day=$(gdate "+%A" -d "$*") || exit
|
day=$(date "+%A" -d "$*") || exit
|
||||||
daynum=$(gdate "+%e" -d "$*") || exit
|
daynum=$(date "+%e" -d "$*") || exit
|
||||||
month=$(gdate "+%m" -d "$*") || exit
|
month=$(date "+%m" -d "$*") || exit
|
||||||
year=$(gdate "+%Y" -d "$*") || exit
|
year=$(date "+%Y" -d "$*") || exit
|
||||||
date=$(gdate "+%Y-%m-%d" -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
|
journal_prefix=~/code/txt/cal
|
||||||
file="$journal_prefix/$date_path/$date.txt"
|
file="$journal_prefix/$date_path/$date.txt"
|
||||||
}
|
}
|
||||||
@ -40,7 +40,6 @@ case "$arg" in
|
|||||||
$PAGER "$file"
|
$PAGER "$file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ if [ ! -f "$file" ]; then
|
|||||||
|
|
||||||
printf "%0.s=" {1..13} >> $file
|
printf "%0.s=" {1..13} >> $file
|
||||||
printf "\n" >> $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
|
truncate -s -1 $file
|
||||||
|
|
||||||
printf "\n$day\n" >> $file
|
printf "\n$day\n" >> $file
|
||||||
|
Loading…
Reference in New Issue
Block a user