Created
May 22, 2021 03:28
-
-
Save GitMurf/292ea4e17e36e0910c191c1e5b39145f to your computer and use it in GitHub Desktop.
Quick Capture an idea by creating a new note and providing the content and title of the new note via two modal pop ups.
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
<%* | |
//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 | |
let qcFileName = await tp.system.prompt("Note Title"); | |
let qcFolderLocation; | |
if(folderOverride) { | |
qcFolderLocation = folderOverride; | |
} else { | |
if(this.app.vault.config.newFileLocation != 'current') { | |
qcFolderLocation = this.app.fileManager.getNewFileParent().path; | |
} else { | |
qcFolderLocation = '/'; | |
} | |
} | |
if(qcFolderLocation != ''){qcFolderLocation = qcFolderLocation + '/'} | |
qcFolderLocation = qcFolderLocation.replace(/\/\//g,'/'); | |
if(qcFolderLocation == '/'){qcFolderLocation = ''} | |
if(qcFolderLocation.startsWith('/')){qcFolderLocation = qcFolderLocation.substring(1)} | |
let qcFilePath = qcFolderLocation + qcFileName + '.md'; | |
let qcFile = this.app.vault.getAbstractFileByPath(qcFilePath); | |
if(!qcFile) { | |
qcFile = await this.app.vault.create(qcFilePath, ''); | |
} | |
if(qcFile) { this.app.vault.modify(qcFile, fileContent); } | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HI. I've been using this quick capture quite a bit, and I'm really liking it.
It would be really great if I could add Bryan Jenks' method of inserting templates based on 1st characters to your quick capture. (see his YouTube explanation here)
His method involves a bunch of else if statements about 1st characters in a file name:
<%* if (tp.file.title.charAt(0) == "z") { %>
<%-tp.file.include("[[Zettelkasten Template]]")%>
<%* } else if (tp.file.title.charAt(0) == "@") { %>
<%-tp.file.include("[[Person]]")%>
<%* } else if (tp.file.title.charAt(0) == "!") { %>
<%-tp.file.include("[[Tweet]]")%>
<%* } else if (tp.file.title.charAt(0) == "%") { %>
<%-tp.file.include("[[Podcast]]")%>
<%* } else if (tp.file.title.charAt(0) == "+") { %>
<%-tp.file.include("[[Youtube]]")%>
<%* } else if (tp.file.title.charAt(0) == "(") { %>
<%-tp.file.include("[[Article]]")%>
<%* } else if (tp.file.title.charAt(0) == "&") { %>
<%-tp.file.include("[[Paper]]")%>
<%* } else if (tp.file.title.charAt(0) == "=") { %>
<%-tp.file.include("[[Thought]]")%>
<%* } else { %>
<%-tp.file.include("[[New Note - Template]]")%>
<%* } _%>
So my idea would be tacking this script onto the end of yours. Any idea how that would work? Sorry...I'm very new to all of this.
Thanks again for your awesome work. It's been so helpful!