Skip to content

Instantly share code, notes, and snippets.

@GitMurf
GitMurf / obsidian.templater.quick-capture.new-note.js
Created May 22, 2021 03:28
Quick Capture an idea by creating a new note and providing the content and title of the new note via two modal pop ups.
<%*
//v1.0: Original script
//Get the content of the new note
let fileContent = await tp.system.prompt("New Note Content");
//Leave this blank if you want to use the default file path location (set to '/' to use root of vault)
let folderOverride = '/';
//Name of the note
@GitMurf
GitMurf / obsidian.templater.search.backlinks.js
Last active June 10, 2023 05:00
Open a [[Link]] under your cursor in Search pane with regex that shows all Backlinks.
@GitMurf
GitMurf / obsidian.templater.block-ref.copy-alias.js
Created May 25, 2021 06:27
Creates block ref on current line and copies to clipboard as asterisk alias link to be pasted somewhere else
<%*
const curSelection = tp.file.selection();
const cmEditorAct = app.workspace.activeLeaf.view.editor;
const curLineNum = cmEditorAct.getCursor().line;
const curLine = cmEditorAct.getLine(curLineNum);
cmEditorAct.setSelection({ line: curLineNum, ch: 0 }, { line: curLineNum, ch: 9999 });
const blockRef = curLine.match(/ \^(.*)/);
let id;
if (!blockRef) {
<%*
const dateFormat = "YYYY-MM-DD";
const dateBasisStr = await tp.system.prompt("When is the meeting?");
if (dateBasisStr) {
function createMessage(daysBefore, dateFormat, dateBasisStr) {
let parseResult;
let newDate;
let parseResultLink;
let nlDatesPlugin = app.plugins.getPlugin('nldates-obsidian');
<%*
//v0.2 - bug fix: when search results match just a file name and no line contents under it
//User can set the following two parameters
const resultFilePrefix = '## ';
const folderLocation = '/search';
const search = app.workspace.getLeavesOfType("search")[0];
const searchTerms = search.view.getQuery();
const arrCount = Array.from(search.view.dom.resultDomLookup);
<%*
//v0.3 - Allow for Include and Exclude variables to have multiple criteria -- Define Qty of results
//VARIABLES TO SET
//How many results to return
const howMany = 1;
//Include the "#" for tags and brackets "[" for pages
const pageOrTag = "#quote";
//The Including and Excluding variables are arrays []. To add multiple values use format: ["one","two"]
//This is a plain text filter of the resulting blocks
@GitMurf
GitMurf / templater.search.block-refs.logseq.js
Created August 13, 2021 19:44
open search pane and add the logseq block ref ID automatically to see block ref source and locations
<%*
//v0.1 - open search pane and add the logseq block ref ID automatically to see block ref source and locations
const search = app.workspace.getLeavesOfType("search")[0];
const editor = app.workspace.activeLeaf.view.editor;
const curLineNum = editor.getCursor().line;
const curLine = editor.getLine(curLineNum);
const blockRef = curLine.match(/\(\([a-zA-Z0-9\-]*\)\)/);
let searchString = "";
@GitMurf
GitMurf / obsidian.templater.search.tasks.current-page.js
Created August 26, 2021 03:31
Run this templater script to open the Search sidebar and search for all open Tasks on the current page
<%*
const search = app.workspace.getLeavesOfType("search")[0];
let thisFile = app.workspace.getActiveFile();
search.view.setSortOrder("byCreatedTime");
search.view.setCollapseAll(false);
search.view.setExtraContext(true);
let myString = thisFile.basename;
search.view.setQuery(`file:("${myString}") task-todo:(/^./)`);
app.workspace.revealLeaf(search);
%>