diff --git a/Obsidian.alfredworkflow b/Obsidian.alfredworkflow index ee38a0c..7186bcc 100644 Binary files a/Obsidian.alfredworkflow and b/Obsidian.alfredworkflow differ diff --git a/Obsidian/info.plist b/Obsidian/info.plist index 8b4844a..d6253f5 100644 --- a/Obsidian/info.plist +++ b/Obsidian/info.plist @@ -125,6 +125,32 @@ + 2FCAB39C-C693-4C37-869B-445FF6C20F9E + + + destinationuid + 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 + + + destinationuid + F4814A0F-C578-420F-A442-A86CF87B7D6A + modifiers + 0 + modifiersubtext + + vitoclose + + + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 @@ -460,6 +486,19 @@ + 8C013085-6514-493F-B7AE-18E02A0961A3 + + + destinationuid + 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 + modifiers + 0 + modifiersubtext + + vitoclose + + + 8C017EEF-38DD-4148-9291-9302EFCE33DE @@ -538,6 +577,19 @@ + AFFCF1F5-F669-4920-A76E-90E812ED8CFC + + + destinationuid + E4ECA02D-673E-4DC4-A33A-A8E524983C6C + modifiers + 0 + modifiersubtext + + vitoclose + + + B768A804-C61E-4133-AB9C-74C6448BFC62 @@ -616,6 +668,19 @@ + F4814A0F-C578-420F-A442-A86CF87B7D6A + + + destinationuid + AFFCF1F5-F669-4920-A76E-90E812ED8CFC + modifiers + 0 + modifiersubtext + + vitoclose + + + F565051F-71D8-42F7-A733-5DA9F39AAEA2 @@ -3413,44 +3478,6 @@ JSON.stringify({items: vaults}) version 3 - - config - - concurrently - - escaping - 0 - script - // NOTE electron bug (if app isn't already opened, it will always open the last opened vault. -// https://discordapp.com/channels/686053708261228577/716028884885307432/755203478413902036 - -console.log('Running script - oterm') - -// get the current app to access the standard additions -app = Application.currentApplication(); -app.includeStandardAdditions = true; - -// get vault name -v="{query}"; - -// https://forum.keyboardmaestro.com/t/open-a-new-terminal-window-for-the-current-finder-folder/1324 -var terminal = Application("Terminal") -terminal.doScript("cd " + v.replaceAll(" ", "\ ")); -terminal.activate(); - scriptargtype - 0 - scriptfile - - type - 7 - - type - alfred.workflow.action.script - uid - 15356FC5-2D9E-4997-B906-08EEA245D255 - version - 2 - config @@ -3524,6 +3551,44 @@ JSON.stringify({items: vaults}) version 3 + + config + + concurrently + + escaping + 0 + script + // NOTE electron bug (if app isn't already opened, it will always open the last opened vault. +// https://discordapp.com/channels/686053708261228577/716028884885307432/755203478413902036 + +console.log('Running script - oterm') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// get vault name +v="{query}"; + +// https://forum.keyboardmaestro.com/t/open-a-new-terminal-window-for-the-current-finder-folder/1324 +var terminal = Application("Terminal") +terminal.doScript("cd " + v.replaceAll(" ", "\ ")); +terminal.activate(); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 15356FC5-2D9E-4997-B906-08EEA245D255 + version + 2 + config @@ -3597,6 +3662,79 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailyheader", { version 1 + + config + + argumenttype + 0 + keyword + odi + subtext + Append to the end of daily note: {query} + text + Append text to daily note + withspace + + + type + alfred.workflow.input.keyword + uid + 8C013085-6514-493F-B7AE-18E02A0961A3 + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodo", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 + version + 2 + + + config + + argumenttype + 0 + keyword + odailytodoheader + subtext + Examples: # To do, ## Tasks + text + Specify todo header to append to: {query} + withspace + + + type + alfred.workflow.input.keyword + uid + 65DEE317-811D-4787-87B4-3909B62061EA + version + 1 + config @@ -3732,15 +3870,111 @@ if (oinotify == "on") { escaping 68 script - ObjC.import('stdlib'); + /* cSpell:disable */ +ObjC.import('stdlib'); +console.log('Running script: oi') -console.log('Running script') +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; -Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodo", { - toValue: "{query}", - exportable: false, - inWorkflow: $.getenv('alfred_workflow_bundleid'), -}); +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +// get inbox note path +var inbox_md = $.getenv('dailytodaypath'); +inbox_md = interpolate_homepath(inbox_md) + +// where to add timestamp +var inbox_timestamp = $.getenv('inbox_timestamp'); + +// get timestamp +var timestamp = $.getenv('date'); + +// escape " +var query = "{query}"; +// query = query.replaceAll('"', '\"'); +query = query.replace(/\"/g, '\"'); // github #25 @jamiew + +if (inbox_timestamp == "append") { + query += (" " + timestamp); +} else if (inbox_timestamp == "prepend") { + query = timestamp + " " + query; +} + +// split paragraphs into separate bullet points +query = query.split("@NEWLISTITEM@") +console.log("query: " + query) + +// function to read utf +// https://github.com/JXA-Cookbook/JXA-Cookbook/issues/25 +ObjC.import('Foundation') +const readFile = function (path, encoding) { + !encoding && (encoding = $.NSUTF8StringEncoding) + const fm = $.NSFileManager.defaultManager + const data = fm.contentsAtPath(path) + const str = $.NSString.alloc.initWithDataEncoding(data, encoding) + return ObjC.unwrap(str) +} + +// read file to append to it +var filetext = readFile(inbox_md); + +// remove newline characters +while (filetext.endsWith("\n")) { + filetext = filetext.slice(0, filetext.length - 1); +} +if (filetext == "") { + console.log("EMPTY NOTE!") +} else { + filetext += "\n"; // leave one newline character +} + +console.log("CURRENT TEXT (string)"); +console.log(filetext) + +// loop through each paragraph and append as separate bullet point +var formatted_text = ''; +for (i = 0; i < query.length; i++) { + + var text2append = query[i]; + + // parse string to remove extra spaces + text2append = text2append.split(" ") + text2append = text2append.filter(i => i.length > 0).join(" ") + + // add bullet point + if (!query[i].startsWith("- ")) { + text2append = "- " + text2append; + } + if (text2append == "- ") { + continue; + } + + if (!text2append.endsWith("\n")) { + text2append += "\n"; + } + console.log("TEXT TO APPEND " + (i + 1)); + console.log(text2append); + formatted_text += text2append; +} + +var final_text = filetext + formatted_text; +console.log("FINAL TEXT") +console.log(final_text) + +// write file +str2write = $.NSString.alloc.initWithUTF8String(final_text); +str2write.writeToFileAtomicallyEncodingError(inbox_md, true, $.NSUTF8StringEncoding, null); + +// notification +var oinotify = $.getenv('oinotify'); +if (oinotify == "on") { + // https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/DisplayNotifications.html + app.displayNotification("Added text to inbox", { withTitle: 'Obsidian Alfred workfow' }) +} scriptargtype 0 scriptfile @@ -3751,31 +3985,10 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodo", { type alfred.workflow.action.script uid - B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 + E4ECA02D-673E-4DC4-A33A-A8E524983C6C version 2 - - config - - argumenttype - 0 - keyword - odailytodoheader - subtext - Examples: # To do, ## Tasks - text - Specify todo header to append to: {query} - withspace - - - type - alfred.workflow.input.keyword - uid - 65DEE317-811D-4787-87B4-3909B62061EA - version - 1 - config @@ -3833,6 +4046,63 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodo", { version 1 + + config + + argument + + passthroughargument + + variables + + date + {date:yyyyMMdd_HHmmss} + + + type + alfred.workflow.utility.argument + uid + AFFCF1F5-F669-4920-A76E-90E812ED8CFC + version + 1 + + + config + + matchmode + 0 + matchstring + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + F4814A0F-C578-420F-A442-A86CF87B7D6A + version + 2 + + + config + + matchmode + 0 + matchstring + + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 + version + 2 + config @@ -3864,6 +4134,37 @@ Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodo", { version 2 + + config + + action + 0 + argument + 2 + focusedappvariable + + focusedappvariablename + + hotkey + 2 + hotmod + 1835008 + hotstring + D + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 2FCAB39C-C693-4C37-869B-445FF6C20F9E + version + 2 + config @@ -4248,6 +4549,9 @@ RELEASE NOTES Full documentation: https://github.com/hauselin/obsidian-alfred +v0.3.7 +- Append text to daily note with odi #30 #31 + v0.3.6 - Remove replaceAll in od and otmr to avoid bug in #25. @@ -4378,9 +4682,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Open Obsidian vault. xpos - 875 + 780 ypos - 1600 + 1595 1BD03BB0-06B9-47F5-9346-7A829C38B248 @@ -4452,6 +4756,24 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 415 + 2FCAB39C-C693-4C37-869B-445FF6C20F9E + + note + Set up: Specify hotkey to append clipboard contents to daily note. + xpos + 1485 + ypos + 2010 + + 333A611A-1A2F-4C2C-BAD8-11A9AE10CAA4 + + note + replace newline + xpos + 1735 + ypos + 1965 + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 note @@ -4482,9 +4804,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note replace newline xpos - 905 + 1010 ypos - 1895 + 1950 3B2DA9A3-761D-467C-BDD7-841584877816 @@ -4536,9 +4858,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Open terminal in vault directory. xpos - 635 + 615 ypos - 1600 + 1560 3F7FA866-52E3-46A9-84EE-80A4D3244647 @@ -4631,9 +4953,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Append text to an inbox note. xpos - 610 + 615 ypos - 1805 + 1820 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 @@ -4678,9 +5000,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Set up: Configure timestamp. xpos - 1020 + 1115 ypos - 1895 + 1955 73853368-ED10-4729-A4D0-E231647C3CF4 @@ -4703,9 +5025,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note replace newline xpos - 810 + 895 ypos - 1895 + 1950 834BB1A9-B643-4448-97B4-B6B6582602CB @@ -4752,6 +5074,15 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 385 + 8C013085-6514-493F-B7AE-18E02A0961A3 + + note + Append text to daily note. + xpos + 1490 + ypos + 1835 + 8C017EEF-38DD-4148-9291-9302EFCE33DE note @@ -4801,11 +5132,11 @@ If the Obsidian app isn't already opened, this workflow will always open the las A7CCBBCE-F078-4780-BF5C-42D9CE64D568 note - Set up: Specify hotkey to append clipboard contents inbox note. + Set up: Specify hotkey to append clipboard contents to inbox note. xpos - 610 + 615 ypos - 1975 + 1985 ADAB8847-A309-4A02-9D42-E8D30C47BC5D @@ -4816,6 +5147,17 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 735 + AFFCF1F5-F669-4920-A76E-90E812ED8CFC + + colorindex + 2 + note + Set up: Configure timestamp. + xpos + 1960 + ypos + 1960 + B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 xpos @@ -4860,9 +5202,9 @@ If the Obsidian app isn't already opened, this workflow will always open the las note Append text to end of note as list item. xpos - 1120 + 1235 ypos - 1865 + 1910 CEC4065E-BADA-44B7-A255-4A9D613685E2 @@ -4889,6 +5231,15 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 465 + E4ECA02D-673E-4DC4-A33A-A8E524983C6C + + note + Append text to end of note as list item. + xpos + 2070 + ypos + 1930 + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 xpos @@ -4912,6 +5263,15 @@ If the Obsidian app isn't already opened, this workflow will always open the las ypos 145 + F4814A0F-C578-420F-A442-A86CF87B7D6A + + note + replace newline + xpos + 1850 + ypos + 1965 + F565051F-71D8-42F7-A733-5DA9F39AAEA2 note @@ -4993,7 +5353,7 @@ If the Obsidian app isn't already opened, this workflow will always open the las dailyheader version - 0.3.6 + 0.3.7 webaddress https://github.com/hauselin/obsidian-alfred diff --git a/README.md b/README.md index 1a2f4f1..32f63be 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Available Alfred features/keywords (contributors in parentheses) - Open inbox note with `oii` or customize your Hotkey to open inbox note. - Turn on/off notifications when adding text to inbox note with `onotify` - Adding/appending text to daily note: `odi` - - You **must** run the `od` command first (once per day) before you can use `odi`. + - You **must** run the `od` command first (once per day) before using `odi`. - Fallback search when there are no results ([@technicalpickles](https://github.com/technicalpickles)) - Open terminal in vault directory: `oterm` - Get help by opening [help vault](https://publish.obsidian.md/help/Index) and [forum](https://forum.obsidian.md/): `o?`