Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GitMurf/a2666cc0a47581bbe58ea54c03cd2845 to your computer and use it in GitHub Desktop.
Save GitMurf/a2666cc0a47581bbe58ea54c03cd2845 to your computer and use it in GitHub Desktop.
<%*
const search = app.workspace.getLeavesOfType("search")[0];
let keyword = await tp.system.prompt('Keyword', '[' + '[Journal');
keyword = keyword.replace(/(\[|\])/g, "\\$1");
const searchQuery = `section:(/^#+ ${keyword}.*\\n+\\S[\\s\\S]*[^\\n]/) OR section:(/^#+ ${keyword}.*/ section:(/[\\s\\S]*[^\\n]/))`;
//Collapse=true, Expand=false
search.view.setCollapseAll(false);
//Show Extra Context: true or false
search.view.setExtraContext(false);
//SortOrder Options: alphabeticalReverse, alphabetical, byModifiedTime, byModifiedTimeReverse, byCreatedTime, byCreatedTimeReverse
search.view.setSortOrder("byCreatedTime");
search.view.setQuery(searchQuery);
app.workspace.revealLeaf(search);
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment