Babashka

by Filipe Silva
5
4
3
2
1
Score: 37/100

Description

The Babashka plugin enables Obsidian users to run Clojure and ClojureScript code blocks directly within their vaults. It integrates with Babashka and Node Babashka to provide scripting capabilities, allowing users to execute code, evaluate results, and print outputs inline or externally. The plugin supports starting and connecting to nREPL servers for interactive sessions, as well as managing dependencies through configurable project files like bb.edn. Vault-specific bindings for metadata and file context are also auto-generated, enhancing the scripting experience. This plugin is ideal for users looking to extend Obsidian's functionality with advanced scripting and automation.

Reviews

No reviews yet.

Stats

56
stars
3,462
downloads
1
forks
1,172
days
1,069
days
1,185
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
7
total issues
6
open issues
1
closed issues
0
commits

Latest Version

3 years ago

Changelog

fix: remove command prefix

README file from

Github

Obsidian Babashka

Obsidian Babashka is a plugin for Obsidian that lets you run Clojure and ClojureScript code blocks via Babashka and Node Babashka respectively.

The main usecase for this plugin is scripting in the context of your vault documents.

Pre-requisites

You'll need to have Babashka installed for clojure codeblocks, and/or Node and Node Babashka installed for clojurescript codeblocks.

You need to set absolute paths for bb (for clojure), and/or node and nbb (for clojurescript) in the plugin settings before evaluating code blocks. You can find these paths using the where command in the terminal.

If you come from a Clojure background but are not familiar with Babashka, keep in mind that Babashka has differences from Clojure, and also has included libraries that are not in Clojure. Take a look at the Babashka and Node Babashka docs to learn more about what's available.

Features

Eval clojure and clojurescript codeblocks

eval-codeblock

Eval codeblock and print value outside

eval-codeblock-and-print-outside

Start and connect to a Babashka nREPL server

async

Vault bindings for current file

vault-bindings

Here's the code if you want to copy paste:

(require '[vault-bindings :as vb])

[vb/*vault-name*
 vb/*vault-path*
 vb/*vault-babashka-path*
 vb/*last-folder-path*
 vb/*last-file-name*
 vb/*last-file-path*
 vb/*vault-plugin-folder*]

Blocking async support in both clj and cljs due to Babashka being awesome

async

Kill all eval and nREPL processes

Use Babashka: Kill all Babashka processes to kill all eval and nREPL processes and their clients.

Dependencies via bb.edn and nbb.edn

You'll find a bb.edn and nbb.edn in the vault babashka dir. It defaults to .babashka, but configurable in the settings.

You can configure source paths, and add dependencies to these files that will be available in the code blocks. NPM packages installed in this directory will also be available to CLJS codeblocks.

If you're syncing the vault and installing a lot of dependencies, you might want to set the vault babashka dir to an absolute path outside the vault, so that the dependencies aren't synced.

How it works

When you call the eval command, the plugin will:

  • use a regex to find all code blocks in the file
  • if you're not in a clojure or clojurescript block, tell you via a notice, and stop
  • send your code to REPL, if any, or call bb -e "..." with your code instead of ..., with " escaped, and with cwd set to the vault babashka dir
  • cap the output at 1000 lines if you have that setting turned on
  • print the output as comments inside the codeblock, or as just text outside, depending on which eval command you ran, and in the developer console (cmd+opt+i in mac, just like chrome)
  • eval errors and stderr show as notices, and in the developer console

Messages are printed to the developer console as debug level, so you will need to turn on the verbose log level in the developer console settings to see them. They are also prefixed with [obsidian-babashka] so you can filter them out.

When you call the repl command, the plugin will:

  • spawn a new Babashka nREPL server process on the settings port
  • wait until it sees the string nREPL
  • connect to the nREPL client
  • show a notice that connection was successful
  • show on the status bar which clients are active
  • setup handlers to remove the process and client on errors or close
  • kill all processes when the plugin is unloaded

When you call the kill processes command, the plugin will:

  • show a notice of how many it's killing
  • send a kill call to all eval and nREPL processes
  • disconnect and destroy all nREPL clients

The vault-bindings namespace is in .babashka/gen/vault-bindings.cljc, and is auto generated each time you eval a code block:

(ns vault-bindings)
;; This file is auto-generated by the Babashka plugin when you eval a codeblock.
;; Don't edit it directly, it will be overwritten.
(def *vault-name* "personal")
(def *vault-path* "/Users/filipesilva/Library/Mobile Documents/iCloud~md~obsidian/Documents/personal")
(def *vault-babashka-path* "/Users/filipesilva/Library/Mobile Documents/iCloud~md~obsidian/Documents/personal/.babashka")
(def *last-folder-path* "/Users/filipesilva/Library/Mobile Documents/iCloud~md~obsidian/Documents/personal//")
(def *last-file-name* "scratch.md")
(def *last-file-path* "/Users/filipesilva/Library/Mobile Documents/iCloud~md~obsidian/Documents/personal/scratch.md")

Roadmap

I'd like to save a couple of codeblocks to use with shortcuts. This way you could run that code over a different context, and even use text selection as an input. I imagine text selection would be added to vault-bindings.

Starting an in-process nbb repl with access to the editor command bindings sounds interesting. It might help with debugging, and also with writing code that interacts with the editor. But it might also be a bad idea, since it could only be force killed by killing the editor process.

Prior Art

Development instructions

How to run the plugin locally

  • Clone this repo.
  • Either clone into the plugin folder, or symlink it there, e.g. ln -s /path/to/obsidian-babashka /path/to/your/vault/.obsidian/plugins/obsidian-babashka.
  • npm i or yarn to install dependencies.
  • npm run dev to start compilation in watch mode.
  • Reload Obsidian to load the plugin initially.
  • Disable/Enable the plugin in community plugins to reload it after making changes.

Releasing new releases

  • Update your manifest.json with the minimum Obsidian version required for your latest release.
  • Run yarn version and input the new version number
  • Create new GitHub release using your new version number as the "Tag version". Use the exact version number in the release name, don't include a prefix v. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
  • Upload the files manifest.json, main.js, styles.css as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
  • Publish the release.

Adding your plugin to the community plugin list

API Documentation

See https://github.com/obsidianmd/obsidian-api

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Note Toolbar
2 years ago by Chris Gurney
Flexible, context-aware toolbars for your notes in Obsidian.
Execute Code
4 years ago by twibiral
Obsidian Plugin to execute code in a note.
Smart Composer
a year ago by Heesu Suh
AI chat assistant for Obsidian with contextual awareness, smart writing assistance, and one-click edits. Features vault-aware conversations, semantic search, and local model support.
MCP Tools
a year ago by Jack Steam
Add Obsidian integrations like semantic search and custom Templater prompts to Claude or any MCP client.
Zoottelkeeper
5 years ago by Akos Balasko
Obsidian plugin of Zoottelkeeper: An automated folder-level index file generator and maintainer.
Shell commands
5 years ago by Jarkko Linnanvirta
Execute system commands via hotkeys or command palette in Obsidian (https://obsidian.md). Some automated events are also supported, and execution via URI links.
Local Backup
3 years ago by GC Chen
Automatically creates a local backup of the vault.
Khoj
3 years ago by Debanjum Singh Solanky
Your AI second brain. Self-hostable. Get answers from the web or your docs. Build custom agents, schedule automations, do deep research. Turn any online or local LLM into your personal, autonomous AI (gpt, claude, gemini, llama, qwen, mistral). Get started - free.
CustomJS
5 years ago by Sam Lewis
An Obsidian plugin to allow users to reuse code blocks across all devices and OSes
Modal forms
3 years ago by Danielo Rodriguez
Define forms for filling data that you will be able to open from anywhere you can run JS
Enveloppe
4 years ago by Mara-Li
Enveloppe helps you to publish your notes on a GitHub repository from your Obsidian Vault, for free!
Note Linker
4 years ago by Alexander Weichart
🔗 Automatically link your Obsidian notes.
AI Providers
a year ago by Pavel Frankov
This plugin is a hub for setting AI providers (OpenAI-like, Ollama and more) in one place.
Syncthing Integration
3 years ago by LBF38
Obsidian plugin for Syncthing integration
Note Companion AI
8 months ago by Benjamin Ashgan Shafii
Note Companion: AI assistant for Obsidian that goes beyond just a chat. (prev File Organizer 2000)
Auto Template Trigger
3 years ago by Numeroflip
An obsidian.md plugin, to automatically trigger a template on new file creation
Pieces for Developers
3 years ago by Pieces For Developers
Pieces' powerful extension for Obsidian-MD that allows users to access their code snippets directly within the Obsidian workspace
Regex Pipeline
5 years ago by No3371
An Obsidian plugin that allows users to setup custom regex rules to automatically format notes.
Prompt ChatGPT
2 years ago by Coduhuey
Personal Assistant
3 years ago by edony
A plugin that harnesses AI agents and streamlining techniques to help you automatically manage Obsidian.
Shortcut Launcher
4 years ago by MacStories
Trigger shortcuts in Apple's Shortcuts app from Obsidian with custom commands.
Text Expander JS
4 years ago by Jonathan Heard
Obsidian plugin: Type text shortcuts that expand into javascript generated text.
AI Tagger
2 years ago by Luca Grippa
Simplify tagging in Obsidian. Instantly analyze and tag your document with one click for efficient note organization.
Apply Patterns
5 years ago by Jacob Levernier
An Obsidian plugin for applying patterns of find and replace in succession.
Attachment Manager
3 years ago by chenfeicqq
Attachment folder name binding note name, automatically rename, automatically delete, show/hide.
YouVersion Linker
3 years ago by Jaanonim
Obsidian plugin that automatically link bible verses to YouVersion bible.
Differential ZIP Backup
2 years ago by vorotamoroz
Enhanced Canvas
a year ago by RobertttBS
When editing on Canvas, properties and Markdown links to notes are automatically updated, enabling backlinks in Canvas.
AI Tagger Universe
a year ago by Hu Nie
An intelligent Obsidian plugin that leverages AI to automatically analyze note content and suggest relevant tags, supporting both local and cloud-based LLM services.
Dataview (to) Properties
9 months ago by Mara-Li
Sync inline Dataview to properties (YAML frontmatter)
Webhooks
5 years ago by Stephen Solka
Connect obsidian to the internet of things via webhooks
Day and Night
4 years ago by Kevin Patel
An Obsidian plugin to automatically switch between day and night themes based on a set schedule
Linkify
4 years ago by Matthew Chan
Arcana
3 years ago by A-F-V
Supercharge your Obsidian note-taking through AI-powered insights and suggestions
RunJS
3 years ago by eoureo
Let's run JavaScript easily and simply in Obsidian.
Automatic Linker
a year ago by Kodai Nakamura
Weekly Review
3 years ago by Brandon Boswell
Auto Filename
2 years ago by rcsaquino
Auto Filename is an Obsidian.md plugin that automatically renames files in Obsidian based on the first x characters of the file, saving you time and effort.
Substitutions
2 years ago by BambusControl
Automatic text replacer for Obsidian.md
InlineAI
a year ago by FBarrca
Snippets
5 years ago by Pelao
JavaScript Init
5 years ago by ryanpcmcquen
Run custom JavaScript in Obsidian.
Packrat
4 years ago by Thomas Herden
Process completed instances of recurring items created by the Obsidian Tasks plugin
User Plugins
4 years ago by mnowotnik
Allows user scripts to use plugin API
Metadata Auto Classifier
2 years ago by Beomsu Koh
AI-powered Obsidian plugin that automatically classifies and generates metadata (tags, frontmatter) for your notes.
Cron
3 years ago by Callum Loh
Obsidian cron / schedular plugin to schedule automatic execution of commands
Gnome Terminal Loader
3 years ago by David Carmichael
Auto Periodic Notes
2 years ago by Jamie Hurst
Obsidian plugin to create new periodic notes automatically in the background and allow these to be pinned in your open tabs. Requires the "Periodic Notes" plugin.
Auto Hyperlink
3 years ago by take6
Automation
2 years ago by Benature
Auto Front Matter
3 years ago by conorzhong
NoteMover shortcut
a year ago by Lars Bücker
Quickly and easily move notes to predefined folders. Perfect for organizing your notes.
Frontmatter generator
2 years ago by Hananoshika Yomaru
A plugin for Obsidian that generates frontmatter for notes
Open File by Magic Date
4 years ago by simplgy
R.E.L.A.X.
2 years ago by Syr
Regex Obsidian Plugin
Wielder
4 years ago by victorb
Clojure inside your Obsidian documents!
Tab Rotator
3 years ago by Steven Jin
Obsidian Rotate opened tabs with a specified time interval
NeuroVox
a year ago by Synaptic Labs
Obsidian plugin for transcription and generation
Run
2 years ago by Hananoshika Yomaru
Generate markdown from dataview query and javascript.
Codeblock Template
3 years ago by Super10
A template plugin that allows for the reuse of content within Code Blocks!一个可以把Code Block的内容重复利用模板插件!
Current View
10 months ago by Lucas Ostmann
Automatically set the view mode (Reading, Live Preview, Source) for notes in Obsidian using folder rules, file patterns, or frontmatter.
Title As Link Text
a year ago by Lex Toumbourou
An Obsidian plugin to set the Link Text using the document title
Snippets Manager
2 years ago by Venkatraman Dhamodaran
Snippets Manager (Text Expander) For Obsidian
Blueprint
3 months ago by François Vaux
Repeatable templates plugin for Obsidian
Steward
6 months ago by Dang Nguyen
A vault-specific agent equipped with agentic capacity, fast search, flexible commands, vault management, and terminals to "jump" into other CLI agents, such as Claude, Gemini, etc.
RSS Copyist
2 years ago by aoout
Get the RSS articles as notes.
Tag Breakdown Generator
3 years ago by Hananoshika Yomaru
Break down nested tags into multiple parent tags
Note 2 Tag Generator
2 years ago by Augustin
Daily note creator
2 years ago by Mario Holubar
Automatically creates missing daily notes.
Personal OS
2 years ago by A.Buot
Note UID Generator
a year ago by Valentin Pelletier
Allow you to automatically generate UID for the notes in your vault.
Todos sort
a year ago by Jiri Sifalda
A plugin for Obsidian that sorts todos within a note
Google Calendar Importer
7 months ago by Fan Li
A simple and light-weighted google calendar importer, allow injecting the events / tasks of a day automatically to your daily notes, or import it to anywhere with a command.
Auto Replacer
10 months ago by Alecell
A live text replacement plugin that applies automatic formatting, corrections, or custom replacements in real-time. Define your own regex-based rules and transformation logic to modify text dynamically as you type.
Timeline Canvas Creator
10 months ago by chris-codes1
Quickly create timeline structured canvases in Obsidian.
Inkporter
a year ago by Ayush Kumar Saroj
Inkporter is an Obsidian plugin that digitizes handwritten notes with smart ink isolation, adaptive theming, and seamless import workflows.
Missing Link File Creator
a year ago by Lemon695
The plugin creates both missing links and the corresponding files.
Last Position
a year ago by saktawdi
Automatically scroll to the last viewed position when opening the markdown document.
Vault File Renamer
a year ago by Louan Fontenele
Vault File Renamer: Automatically standardizes file names to GitHub style (lowercase, no accents, only -, ., _) while preserving folder structure and file contents.
pycalc
a year ago by pycalc
LinkMagic
2 years ago by AndyReifman
AI integration Hub
a year ago by Hishmat Salehi
A modular AI integration hub for Obsidian
Template Filename
a year ago by Callum Alpass
Obsidian plugin for creating notes with templatable filenames
Note Linker with Previewer
2 years ago by Nick Allison
Obsidian Plugin to find and Link notes
Sentinel
a year ago by Giorgos Sarigiannidis
A plugin for Obsidian that allows you to update properties or run commands based on document visibility changes.
tidit
a year ago by codingthings.com
tidit is an Obsidian - https://obsidian.md - plugin that adds timestamps to your document as you type — when you want it, how you want it, where you want it.
Task Mover
a year ago by Mariia Nebesnaia
A plugin for obsidian to move unfinished tasks to the daily note automatically
Organized daily notes
a year ago by duchangkim
Automatically organizes your daily notes into customizable folder structures for better organization and easier navigation.
URL Formatter
8 months ago by Thomas Snoeck
Automatically formats specific URLs pasted into Obsidian into clean Markdown links.
AI Note Tagger
a year ago by Jasper Mayone
Auto tagging obsidian notes w/ AI
Rapid AI
2 years ago by Rapid AI
AI Assistant for selected text and generating content with Markdown. Shortcuts and quick action buttons provide instant AI assistance. It provides a high availability API for unlimited Chat GPT request rates, so you can ensure smooth work for any workload.
Hotstrings
a year ago by wakywayne
Runsh
a year ago by Ddone
A simple plugin that allows to run shell commands from obsidian.
Tasks Cleaner
a year ago by lowit
🧹 Tasks Cleaner is a plugin for Obsidian that helps you automatically remove old completed tasks from your Markdown notes
Varinote
a year ago by Giorgos Sarigiannidis
A plugin for Obsidian that allows you to add variables in Templates and set their values during the Note creation.
Rsync
a year ago by Ganapathy Raman
An Obsidian plugin to perform sync files between machines using Rsync
Memos AI Sync
a year ago by leoleelxh
obsidian-memos-sync-plugin,将 Memos 内容同步到 Obsidian 的插件,提供无缝集成体验。
Watched-Metadata
2 years ago by Nail Ahmed
Watches for changes in metadata and updates the note content accordingly.
Jura Links
2 years ago by Lukas Collier & Emi Le
Verlinke deine Normangaben, Aktenzeichen oder Fundstellen in deiner Obsidian Notiz mit Gesetzesanbietern.
Mastodon Threading
a year ago by El Pamplina de Cai
Obsidian plugin to compose and post threads to Mastodon
NotePix
8 months ago by Ayush Parkara
NotePix automatically uploads images, screenshots from your Obsidian vault to a designated GitHub repository. It then seamlessly replaces the local link with a fast URL, keeping your vault lightweight and portable.
Discord Message Sender
10 months ago by okawak
Obsidian Plugin: Send messages from a Discord channel to your Vault
Plugin REPL
a year ago by readwithai
An in-note Read Evaluate Print Loop to execute JavaScript within Obsidian
Daily Note Structure
2 years ago by db-developer
This obsidian plugin creates a structure for your daily notes
Note From Form
a year ago by Sergei Kosivchenko
Obsidian plugin that adds support to define input form and generate notes based on it
Auto Daily Note
a year ago by John Dolittle
Fast Image Auto Uploader
2 years ago by Longtao Wu
upload images from your clipboard by gopic
Daily Notes Automater
a year ago by David Pedrero
Copy Local Graph Paths
a year ago by Amy Z
copy-local-graph-paths is a simple Obsidian plugin that copies the paths of notes linked to your current page.
Open or Create File
6 months ago by Ilya Paripsa
Set up Obsidian commands that create or open files based on predefined patterns.
Blog AI Generator
a year ago by Gareth Ng
Obsidian Plugin: generate blog via AI based on the current note.
Paste as Embed
2 years ago by Matt Laporte
Obsidian plugin to paste contents of clipboard into a new note, and embed it in the active note.
Current File
2 years ago by Mark Fowler
An Obsidian plugin to allows external applications to know what file Obsidian is currently viewing
Notes 2 Tweets
2 years ago by Tejas Sharma
Generate and schedule tweets automatically from your notes on Obsidian
IMSwitch in Math Block
a year ago by XXM
Random Wikipedia Article
9 months ago by SpencerF718
An Obsidian plugin to generate a note of a random Wikipedia article.
Hanko
a year ago by Telehakke
Obsidian plugin.
Handlebars Dynamic Templating
3 months ago by Hide_D
Handlebars dynamic templating. Define template files and use them dynamically via hb blocks. Template recursion is also possible.
KOI Sync
a year ago by Luke Miller
Content OS
8 months ago by eharris128
Post to LinkedIn from within Obsidian
Move Cursor On Startup
8 months ago by Jared Kelnhofer
Obsidian plugin to move the cursor to the right and back to the left when starting up. Why? To keep DataView expressions from not running on the first load of, say, your Home file.
One Step Wiki Link
a year ago by Busyo
用于 Obsidian 一步插入当前界面匹配到的所有外链(维基链接)
EUpload
a year ago by Appleex
Obsidian 插件,专用于上传文件到存储仓库。目前支持 Lskypro(兰空图床),后续有需求会引入其它存储方式,如:Github/Gitee等等。
Clojure Plugin Host
a year ago by Vladimir "farcaller" Pouzanov
A Clojure plugin host, allowing the creation of simple Clojure-based plugins right inside Obsidian