tw
Command-line tool for managing TiddlyWiki files. Use when working with TiddlyWiki (.html) files, tiddlers, or when the user mentions TiddlyWiki operations.
When & Why to Use This Skill
The TiddlyWiki CLI (tw) skill is a powerful command-line interface designed for the comprehensive management of TiddlyWiki files. It enables users to programmatically interact with tiddlers, perform advanced filtering, and automate wiki maintenance. By bridging the gap between local file systems and TiddlyWiki's unique architecture, this tool is essential for developers and power users looking to enhance their personal knowledge management (PKM) and documentation workflows through automation and CLI-based editing.
Use Cases
- 1. Automated Content Integration: Programmatically insert or update tiddlers from external scripts or data sources, allowing for automated logging and knowledge base synchronization.
- 2. Batch Processing and Filtering: Use TiddlyWiki filter expressions via the CLI to perform bulk operations, such as tagging, field updates, or content extraction across hundreds of notes.
- 3. Local Development and Hosting: Serve TiddlyWiki files locally with live-reload and WebDAV support, creating a professional environment for intensive writing and real-time browser previews.
- 4. Data Migration and Backup: Seamlessly export wiki content to JSON for secure backups or import structured data from other productivity tools to centralize information.
| name | tw |
|---|---|
| description | Command-line tool for managing TiddlyWiki files. Use when working with TiddlyWiki (.html) files, tiddlers, or when the user mentions TiddlyWiki operations. |
TiddlyWiki CLI (tw)
Quick Reference
tw is a Python-based CLI for managing single-file TiddlyWiki wikis.
Location: ~/dotfiles/tiddlywiki/bin/tw
Basic syntax:
tw [<wiki_path>] <command> [args]
Common Commands
Reading/Listing
ls- List all tiddlerscat <tiddler>- Display tiddler contents (cat format: title, tags, other fields, blank line, text)json <tiddler> [...]- Output tiddler(s) as JSON (use--allfor all tiddlers)get <tiddler> <field>- Get a specific field valuefilter <expression>- Evaluate TiddlyWiki filter expression
Writing/Editing
init <dest_path>- Create a new empty wikitouch <tiddler> [text]- Create or update a tiddlerset <tiddler> <field> <val>- Set a field valueedit <tiddler>- Edit tiddler in $EDITOR (opens interactive editor)append <tiddler> [text]- Append text to tiddlerinsert <json>- Insert/replace tiddler(s) from JSONreplace <content>- Insert/replace from cat format (reads from stdin)rm <tiddler>- Remove a tiddler
Serving
serve [--host HOST] [--port PORT] [--readonly]- Serve wiki with live reloadwebdav [--host HOST] [--port PORT] [--readonly]- Serve tiddlers via WebDAV
Utilities
detect- Detect wiki format (modern or legacy)filetype-map- Output MIME type to filetype mapping as JSONmimetype <filename>- Get MIME type for a file extensioninstall_plugin- Install live reload plugin
Important Notes
- Wiki path: Always specify the wiki path as the first argument
- Cat format: Output format is
title: X\ntags: Y\nfield: Z\n\ntext content - Interactive commands:
editopens $EDITOR - don't use in automated scripts, usereplaceinstead - Filter expressions: Supports TiddlyWiki filter syntax (see tw_filter_progress.md for coverage)
- Live reload: Use
install_pluginonce, thenserveto get auto-refresh in browser
Examples
# List all tiddlers in a wiki
tw ~/wiki.html ls
# Create a new tiddler
tw ~/wiki.html touch "MyTiddler" "This is the content"
# Get a field value
tw ~/wiki.html get "MyTiddler" tags
# Set a field
tw ~/wiki.html set "MyTiddler" tags "foo bar"
# Pipe content to replace (non-interactive)
echo -e "title: Test\ntags: demo\n\nContent here" | tw ~/wiki.html replace
# Export all tiddlers as JSON
tw ~/wiki.html json --all > backup.json
# Filter tiddlers (find all tagged "journal")
tw ~/wiki.html filter "[tag[journal]]"
# Serve wiki with live reload on port 8080
tw ~/wiki.html serve --port 8080
Integration with Other Tools
- Pipe JSON to/from
jqfor processing - Use with
nvimvia $EDITOR for editing - Combine with shell scripts for batch operations
- WebDAV server allows mounting as filesystem