commit 4f4afa90d0388254cb34a012230a679419c48d08 Author: Tissevert Date: Tue Mar 9 15:26:26 2021 +0100 First draft of a set of tools to handle my zettelkasten diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8a17748 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +prefix ?= ~/.local +bindir = $(prefix)/bin +datadir = $(prefix)/share +desktopdir = $(datadir)/applications +ifeq ($(prefix), ~/.local) +plugindir ?= ~/.vim/plugin +else +plugindir ?= $(datadir)/vim/addons/autoload +endif +targets = $(bindir)/titfiche.sh $(desktopdir)/titfiche.desktop $(plugindir)/titfiche.vim + +all: $(targets) + +$(bindir)/titfiche.sh: titfiche.sh + mkdir -p $(bindir) + install -m 555 $^ $@ + +$(desktopdir)/titfiche.desktop: titfiche.desktop + mkdir -p $(desktopdir) + install -m 444 $^ $@ + +$(plugindir)/titfiche.vim: titfiche.vim + mkdir -p $(plugindir) + install -m 444 $^ $@ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e17273f --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# Titfiche + +Titfiche is the simplest collection of scripts / config files I could devise to handle my [zettelkasten](https://zettelkasten.de/). + +> Toi, tu tombes des arbres, nous… on fait des p'tites fiches. diff --git a/titfiche.desktop b/titfiche.desktop new file mode 100644 index 0000000..1f9a123 --- /dev/null +++ b/titfiche.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Type=Application +Name=Titfiche +GenericName=Zettelkasten manager +Comment=Edit your zettelkasten +Categories=Utility;TextEditor;GTK; +Icon=text-editor +Keywords=zettel;notes; +Exec=titfiche.sh %f +TryExec=titfiche.sh +StartupNotify=true +Terminal=false +MimeType=text/markdown; + +Comment[es]=Edite su zettelkasten +Comment[fr]=Éditez vos zettelkasten +Comment[ja]=ゼッテル札を編む diff --git a/titfiche.sh b/titfiche.sh new file mode 100755 index 0000000..355caa6 --- /dev/null +++ b/titfiche.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +[ -n "${TITFICHE_VIM_INSTANCE}" ] || TITFICHE_VIM_INSTANCE="TITFICHE" +REMOTE=" --remote" +gvim --serverlist | grep -q "${TITFICHE_VIM_INSTANCE}" || REMOTE='' +EDITOR="gvim --servername ${TITFICHE_VIM_INSTANCE}${REMOTE}" +export TITFICHE_MODE=1 + +if [ -z "${TITFICHE_HOME}" ] +then + export TITFICHE_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}/titfiche" +else + export TITFICHE_HOME="${TITFICHE_HOME%/}" +fi + +if [ -n "${1}" ] +then + mkdir "${TITFICHE_HOME}" + $EDITOR "${1}" +else + ID="$(date "+%Y/%m/%d/%H:%M")" + mkdir -p "${TITFICHE_HOME}/${ID%/*}" + + $EDITOR -c "normal A# /${ID} " -c 'startinsert!' "${TITFICHE_HOME}/${ID}.md" +fi diff --git a/titfiche.vim b/titfiche.vim new file mode 100644 index 0000000..7e4b016 --- /dev/null +++ b/titfiche.vim @@ -0,0 +1,8 @@ +if $TITFICHE_MODE + set isfname+=: + set includeexpr=substitute(v:fname,'/','','') + cd $TITFICHE_HOME + nnoremap "zciw(/#)%i[z]% + vnoremap "zc(/#)%i[z]% + inoremap (/#)%i[] +endif