Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 821 Bytes

(Templater) Add New Task To 'Quick Tasks' File.md

File metadata and controls

18 lines (16 loc) · 821 Bytes

This template adds a task to the top of specified 'Quick Tasks.md' file (used to parse it with Tasks queries). Task description taken from prompt. See also a quick way to clean 'Quick tasks' file of completed tasks.

<%*
let filePath = 'Path/Quick Tasks.md';  // Insert your 'Path/Filename'! Directory must exist
let file = this.app.vault.getAbstractFileByPath(filePath);
if(!file) {
    file = await this.app.vault.create(filePath, '');
}

let newTask = await tp.system.prompt("New Task");
let appendTask = '- [ ] ' + newTask;
let curContent = await this.app.vault.read(file);
let newContents = appendTask + '\n' + curContent;
this.app.vault.modify(file, newContents);
%>