The Current File plugin enables seamless integration between Obsidian and external tools by exposing the current file being viewed in the desktop application. It automatically generates a JSON file containing the file's path, vault location, and full directory path, which can be accessed by external programs. This functionality allows users to create workflows or scripts, such as updating daily notes, checking link validity, or automating specific tasks based on the current file. The plugin enhances the flexibility of working with Obsidian's markdown files, making it ideal for advanced or custom workflows.
Plugin for Obsidian that allows external programs to
determine what the current file you're looking at in the the desktop
application.
One of the great things about Obsidian is that it just works on a directory
of Markdown (an "Obsidian Vault"). You can manipulate the contents of the files
with external programs while Obsidian is open and it'll reflect the changes in
the application. You're not bound to Obsidian and can use any tools you want
in your workflow.
This plugin allows external programs to be able to determine what file you're
looking at in the Obsidian desktop application. For example, you could bind a
keyboard shortcut to execute a Perl script to add the path to the current note
to your daily note. You could have a Go program that checks if every link in the
current file is still reachable and removes those that are not. The
possibilities are endless.
By default every time Obsidian starts looking at a new file in a vault that has
this plugin installed, a JSON file will be written to
.obsidian-current-file.json
in your home directory (or current profile directory
on Windows))
{
"file": "Sorted/Daily/2024-07-19.md",
"vault": "/Users/markfowler/Obsidian/MyVault",
"fullpath": "/Users/markfowler/Obsidian/MyVault/Sorted/Daily/2024-07-19.md"
}
You can change where the file will be written to in the settings for this plugin.
Obsidian natively supports a x-callback-url scheme to allow you to determine
what file it's looking at, although this requires you to be running an
application with a custom url scheme to receive the information (or be running a
webserver and not mind having Obsidian spawn a web browser window).
More information on this feature can be found in the
Obsidian Help Documentation.
MIT License
Copyright (c) 2024 Mark Fowler <mark@twoshortplanks.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.