shithub: zet

Download patch

ref: 44efe644d6962daaf2f299560633221fd43abcc3
author: sirjofri <sirjofri@sirjofri.de>
date: Fri Apr 28 12:49:33 EDT 2023

adds files

--- /dev/null
+++ b/README
@@ -1,0 +1,15 @@
+Zettelkasten tools for acme
+
+
+Bind this directory to /bin/zet (or somewhere else) and use the tools:
+
+- znew : create new zettelkasten note (timestamp.txt by default)
+- zls : list existing zettelkasten notes
+- ztag : list tags of this note
+- zlstag : list all notes that match the parameter tag
+
+Note: the tools work with all .txt files in the working directory.
+
+First line in note is the title, tags are denoted as #[tag .
+
+Bugs: Sure.
--- /dev/null
+++ b/zlib
@@ -1,0 +1,13 @@
+fn zlist {
+	if (~ $1 '') {
+		echo No files to list
+		exit
+	}
+	if not 
+		files=$*
+	for (file in $files) {
+		title=`{sed 1q $file}
+		tags=`{ztag $file}
+		echo $file^'	'^$"title^'	'^$"tags
+	}
+}
--- /dev/null
+++ b/zls
@@ -1,0 +1,31 @@
+#!/bin/rc
+
+rfork en
+dir=`{basename -d `{src -n $0}}
+. $dir/zlib
+
+if(~ $1 '')
+	files=*.txt
+if not
+	files=$*
+
+fn construct {
+	for (file in $files) {
+		title=`{sed 1q $file}
+		tags=`{ztag $file}
+		echo $file^'	'^$"title^'	'^$"tags
+	}
+}
+
+if(! test -f /mnt/acme/index) {
+	zlist $files
+	exit
+}
+wd=`{pwd}
+cd /mnt/acme/new
+echo name $wd/-Zettelkasten >ctl
+@{cd $wd; zlist $files} > data
+echo scratch >ctl
+echo nomenu >ctl
+echo nomark >ctl
+echo clean >ctl
--- /dev/null
+++ b/zlstag
@@ -1,0 +1,38 @@
+#!/bin/rc -e
+
+rfork en
+dir=`{basename -d `{src -n $0}}
+. $dir/zlib
+
+if(~ $1 '') {
+	echo usage: $0 tag
+	exit usage
+}
+
+tag=$1
+
+files=()
+
+tagsplit=' 	,
+'
+
+for(f in *.txt) {
+	tags=`$tagsplit{ztag $f}
+	for(t in $tags) {
+		if(~ $"t $"tag)
+			files=($files $f)
+	}
+}
+
+if(! test -f /mnt/acme/index) {
+	zlist $files
+	exit
+}
+wd=`{pwd}
+cd /mnt/acme/new
+echo name $wd/-Zettelkasten >ctl
+@{cd $wd; zlist $files} >data
+echo scratch >ctl
+echo nomenu >ctl
+echo nomark >ctl
+echo clean >ctl
--- /dev/null
+++ b/znew
@@ -1,0 +1,8 @@
+#!/bin/rc
+
+file=`{pwd}
+if(! ~ $1 '') file=$1
+
+d=`{date -f 'YYYYMMDDhhmmss'}
+touch $"file^/^$"d.txt || exit 'unable to touch file'
+plumb $"file^/^$"d.txt
--- /dev/null
+++ b/ztag
@@ -1,0 +1,13 @@
+#!/bin/rc
+
+file=$1
+if(! ~ $#% 0) file=$%
+if(! ~ $#* 0) file=$1
+nl='
+'
+
+if(~ $file '') exit 'no file given'
+
+tags=`{cat $file | sed 's/[ 	]+/\n/g' | sort | grep '^#\[' | sed 's/^#\[//' | sed 's/$/, /g' | tr -d $nl | sed 's/, $//g'}
+
+echo $tags