Skip to content

Instantly share code, notes, and snippets.

@GitMurf
GitMurf / obsidian.templater.search.dnp.backlinks.js
Created September 23, 2021 19:45
obsidian.templater.search.dnp.backlinks.js
<%*
const search = app.workspace.getLeavesOfType("search")[0];
search.view.setSortOrder("byCreatedTime");
search.view.setCollapseAll(false);
search.view.setExtraContext(true);
const dnp = tp.date.now('YYYY-MM-DD');
const dnp2 = tp.date.now('YYYY_MM_DD');
let myString = `((file:${dnp2} task-todo:"[ ]") OR ((/Due Date: .*\\[\\[${dnp}\\]\\].*/ OR /due date: \\[[0-9, -]*${dnp}[0-9, -]*\\]/) task-todo:"[ ]") OR (file:${dnp} task-todo:"[ ]") OR (task-todo:"${dnp}") OR section:(/^\#.*${dnp}/ "[ ]") OR section:(/^\#.*${dnp}/ section:("[ ]"))) -file:("weekly review")`;
search.view.setQuery(`${myString}`);
app.workspace.revealLeaf(search);
<%*
let dueDateStr = await tp.system.prompt("Enter Date", "Tomorrow");
let parseResult;
let parseResultLink;
let myString = '';
if(dueDateStr) {
let findDays = dueDateStr.split(';');
let myDateStr = findDays[0];
if(myDateStr) {
let nlDatesPlugin = this.app.plugins.getPlugin('nldates-obsidian');
@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);
%>
@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 = "";