(no title)
koozz | 1 year ago
Running `journal` quickly allows you to add a line to your journal. This will fallback to ~/.journal.log unless you have a .journal.log file in the current directory or any of its parents. Running `journal show` outputs the tail -5 of that journal. Running `journal init` creates a log in the current folder.
Adding .journal.log to your global gitignore is recommended.
$ cat ~/.config/fish/functions/journal.fish
function journal set -f journal ~/.journal.log
if test "$argv[1]" = "init"
set -f journal .journal.log
else
set -f journal ~/.journal.log
end
touch $journal
set -l dirparts (string split "/" (pwd))
set -l dircount (count $dirparts)
for x in (seq $dircount -1 2)
set -l dir (string join "/" $dirparts[1..$x])
if test -f $dir/.journal.log
set -f journal $dir/.journal.log
break
end
end
if test "$argv[1]" = "show"
printf "Last journal entries from: %s\n" "$journal"
tail -5 $journal
else
printf "Add to journal: %s\n" "$journal"
read -P "Addition: " -l line
if test -z $line
printf "Nothing added.\n"
return
end
printf "%s\n" "$line" >> $journal
end
end
No comments yet.