Skip to content

mcmanussliam/obsidian-actions

Repository files navigation

Obsidian Code View Banner

Obsidian

Obsidian Actions

Obsidian Actions is a lightweight Obsidian plugin for small automations. Each action has three parts:

  • a trigger
  • an execution type
  • a code body

Use it to run commands, call scripts, show notices, or respond to Obsidian events without building a full plugin. See documentation here.

Install

Community Plugin

Since this plugin isn't officially released in the Community Plugins store yet, the easiest way to install it is with Obsidian BRAT, which lets you install plugins directly from GitHub.

After BRAT is enabled:

Manual Install

Copy the plugin files into:

<vault>/.obsidian/plugins/actions

Required files:

  • main.js
  • styles.css
  • manifest.json

Quick Start

  1. Open Settings -> Actions.
  2. Create a new action.
  3. Choose a trigger.
  4. Choose js or shell.
  5. Write the code.
  6. Restart Obsidian to register commands and hooks.

Start with a manual JavaScript action:

new Notice("Action ran");

Suggested fields:

  • hook: manual
  • type: js
  • enabled: true

Triggers

Hook Behavior
manual Runs when you trigger it from Obsidian
startup Runs when the plugin loads
interval Runs on a cron schedule
createFile Runs when a file is created
modifyFile Runs when a file is modified
deleteFile Runs when a file is deleted
renameFile Runs when a file is renamed

Execution Types

Type Use It For
js Obsidian-aware automations that need app APIs, notices, or editor context
shell Existing scripts, CLI tools, or system workflows

Available JavaScript helpers include:

  • app
  • vault
  • workspace
  • metadataCache
  • fileManager
  • Notice
  • Modal
  • Setting
  • FuzzySuggestModal
  • exec

Runtime Variables

Before an action runs, the plugin renders its code with Mustache templates such as {{file_name}} or {{path}}.

Available variables include:

  • path
  • relative_path
  • extension
  • selected
  • word_count
  • vault_name
  • file_name
  • file_name_with_ext
  • content
  • timestamp
  • date
  • time

Example:

echo "Processing {{{file_name_with_ext}}} at {{time}}"

Compatibility

Type Desktop Mobile
js Supported Depends on the APIs and code you use
shell Supported where Obsidian can execute local shell commands Not reliable on mobile

shell actions are best suited to desktop environments with access to local scripts, binaries, and a usable shell environment.

Examples

Open the current file in VS Code:

/path/to/code "{{{path}}}"

Show the current file in a notice:

new Notice(`Current file: {{{file_name_with_ext}}}`);

Run a backup script on a schedule:

/absolute/path/to/backup-vault.sh

About

An Obsidian Plugin allowing you to create and manage custom actions.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors