First draft of a set of tools to handle my zettelkasten

This commit is contained in:
Tissevert 2021-03-09 15:26:26 +01:00
commit 4f4afa90d0
5 changed files with 79 additions and 0 deletions

24
Makefile Normal file
View File

@ -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 $^ $@

5
README.md Normal file
View File

@ -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.

17
titfiche.desktop Normal file
View File

@ -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]=

25
titfiche.sh Executable file
View File

@ -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

8
titfiche.vim Normal file
View File

@ -0,0 +1,8 @@
if $TITFICHE_MODE
set isfname+=:
set includeexpr=substitute(v:fname,'/','','')
cd $TITFICHE_HOME
nnoremap <C-l> "zciw(/<C-r>#)<Esc>%i[<C-r>z]<Esc>%
vnoremap <C-l> "zc(/<C-r>#)<Esc>%i[<C-r>z]<Esc>%
inoremap <C-l> (/<C-r>#)<Esc>%i[]<Left>
endif