This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
/* USER CONFIG SETTINGS */ | |
const collapsed = false; | |
const showMoreContext = false; | |
//SortOrder Options: alphabeticalReverse, alphabetical, byModifiedTime, byModifiedTimeReverse, byCreatedTime, byCreatedTimeReverse | |
const sortOrder = "byModifiedTime"; | |
/* END OF CONFIG SETTINGS */ | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
let thisFile = app.workspace.getActiveFile(); | |
let myString = thisFile.basename; | |
//Escape any special characters from the file name | |
myString = myString.replace(/[-[\]{}()+?.,\\^$|#]/g, '\\$&'); | |
//Collapse=true, Expand=false | |
search.view.setCollapseAll(collapsed); | |
//Show Extra Context: true or false | |
search.view.setExtraContext(showMoreContext); | |
//SortOrder Options: alphabeticalReverse, alphabetical, byModifiedTime, byModifiedTimeReverse, byCreatedTime, byCreatedTimeReverse | |
search.view.setSortOrder(sortOrder); | |
search.view.setQuery(`/\\[\\[[^\\[\\]\\n]*\\/?${myString}(\\]\\]|\\|)/`); | |
app.workspace.revealLeaf(search); | |
return; | |
%> |
Author
GitMurf
commented
Mar 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment