A simple LaTeX-centric Zettelkasten written in Bash.
xettelkasten (or xk
for short) is a command-line tool designed to help you manage a Zettelkasten—a personal knowledge management system—using LaTeX documents. It streamlines the creation, organization, and interconnection of notes (zettels), making it easier to build a robust and scalable knowledge base.
If you're using Nix with Flakes enabled:
Clone the Repository:
git clone https://github.com/lentilus/xk.git
cd xettelkasten
Build the Package:
nix build
Install the Binary:
nix profile install .#default
This will install xk
to your Nix profile.
Clone the Repository:
git clone https://github.com/lentilus/xk.git
cd xettelkasten
Install Dependencies:
Ensure that at least bash
, and some LaTeX distribution (e.g., texlive-full
) are installed on your system.
Copy the Executable:
sudo cp bin/xettelkasten /usr/local/bin/xk
sudo chmod +x /usr/local/bin/xk
Copy the Libraries and Configuration Files:
sudo mkdir -p /usr/local/lib/xk
sudo cp -r lib/* /usr/local/lib/xk
sudo mkdir -p /usr/local/etc/xk
sudo cp -r etc/* /usr/local/etc/xk
Initialize a new zettelkasten in the default location:
xk init
This creates a new zettelkasten directory with necessary templates and configuration.
Create a new zettel (note):
xk insert -z "My First Zettel"
This will generate a zettel with the name My_First_Zettel
.
Open the zettel in your preferred text editor:
nano "$(xk path -z "My First Zettel")/zettel.tex"
Add your content between the \begin{document}
and \end{document}
tags.
Navigate to your zettel directory and compile using LaTeX:
cd "$(xk path -z "My First Zettel")"
pdflatex zettel.tex
This will generate a zettel.pdf
file in the same directory.
xk <command> [subcommand] [options]
Your zettelkasten directory (by default ~/.local/xettelkasten/my-zettel-kasten
) will have the following structure:
my-zettel-kasten/
├── zettel1/
│ ├── zettel.tex
│ ├── references
│ └── tags
├── zettel2/
│ ├── zettel.tex
│ ├── references
│ └── tags
├── preamble.sty
├── xettel.cls
└── README.md
lib/default_config
. Contains default settings.~/.config/xk/config
to override defaults.Example ~/.config/xk/config
:
ZETTEL_DATA="$HOME/Documents/zettelkasten"
LOG_FILE="$HOME/.local/share/xk/log.txt"
Customize templates in etc/templates/
:
zettel.tex
preamble.sty
xettel.cls
xk init
Initializes a new zettelkasten with default templates and configuration.
xk insert -z "Zettel Name"
xk ls
Lists all existing zettels.
xk rm -z "Zettel Name"
Deletes the specified zettel and its contents.
xk mv -z "Old Name" -n "New Name"
xk path -z "Zettel Name"
Outputs the full path to the specified zettel.
xk ref insert -z "Zettel Name" -r "Reference Name"
Adds a reference from "Zettel Name" to "Reference Name".
xk ref ls -z "Zettel Name"
Displays all references in the specified zettel.
xk ref rm -z "Zettel Name" -r "Reference Name"
Removes the specified reference from the zettel.
xk tag insert -z "Zettel Name" -t "Tag Name"
Adds a tag to the specified zettel.
xk tag ls -z "Zettel Name"
Displays all tags associated with the zettel.
xk tag rm -z "Zettel Name" -t "Tag Name"
Removes the specified tag from the zettel.
xk git init
Initializes a Git repository in the zettelkasten directory.
xk git publish
Adds all changes, commits with a timestamp message, and pushes to the remote repository.
xk git <git-command> [args]
Runs the specified Git command in the zettelkasten directory.
xk script <script_name> [args]
Executes a user-defined script located in:
~/.config/xk/userscripts/
<installation_path>/share/xk/userscripts/
Note : User-defined scripts are prioritized over the built-in scripts, so functionality of builtins can be overriden by defining a custom script with the same name.
The zettel LaTeX files use a custom class (xettel.cls
) and preamble (preamble.sty
) for consistent formatting.
preamble.sty
to change the formatting, packages, or commands used in all zettels.xettel.cls
to alter the document class settings.You can adjust various settings by editing the configuration files or exporting environment variables:
Contributions are welcome! If you'd like to contribute:
If you encounter any issues or have questions, feel free to open an issue on the GitHub repository.
Happy Zetteling!