Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GitMurf/292ea4e17e36e0910c191c1e5b39145f to your computer and use it in GitHub Desktop.
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.
<%*
//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); }
%>
@anoriginalmoniker
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment