Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitMurf/35f56b3c803581de593aea8dc68c3288 to your computer and use it in GitHub Desktop.
Save GitMurf/35f56b3c803581de593aea8dc68c3288 to your computer and use it in GitHub Desktop.
<%*
//Specify your typical default location here so it is always top of the list to reset to
const myDefaultLocation = "new";
//Specify the list of folders you would like to have an option to switch between
const changeToPaths = [myDefaultLocation, 'new/tasks', 'templater', '/'];
const folderTypeSetting = app.vault.getConfig('newFileLocation');
if(folderTypeSetting !== "folder") {
new Notice(`It appears you currently are not using the setting to specify a folder to save new notes to.`, 10000);
} else {
const currentFolderSetting = app.vault.getConfig('newFileFolderPath');
if(currentFolderSetting) {
const chosenFolder = await tp.system.suggester(changeToPaths, changeToPaths, false, `Change default folder location. Currently: "${currentFolderSetting}"`);
if(chosenFolder) {
app.vault.setConfig("newFileFolderPath", chosenFolder);
new Notice(`Changed new file location from "${currentFolderSetting}" to "${chosenFolder}"`, 10000);
} else {
new Notice(`Did not select an item. Keeping the new file location as "${currentFolderSetting}"`, 10000);
}
}
}
return;
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment