diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5217ec --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/tests \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..33caa6d --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +build: + zip Obsidian.alfredworkflow info.plist *.png diff --git a/Obsidian.alfredworkflow b/Obsidian.alfredworkflow index a8a6284..45ef34d 100644 Binary files a/Obsidian.alfredworkflow and b/Obsidian.alfredworkflow differ diff --git a/Obsidian/3D9E86C3-15F0-4B5E-AC66-0BA4B3524F7C.png b/Obsidian/3D9E86C3-15F0-4B5E-AC66-0BA4B3524F7C.png new file mode 100644 index 0000000..82e2169 Binary files /dev/null and b/Obsidian/3D9E86C3-15F0-4B5E-AC66-0BA4B3524F7C.png differ diff --git a/Obsidian/5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3.png b/Obsidian/5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3.png new file mode 100644 index 0000000..82e2169 Binary files /dev/null and b/Obsidian/5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3.png differ diff --git a/Obsidian/C016E20E-3F44-4372-90DC-1B00DA8C07F8.png b/Obsidian/C016E20E-3F44-4372-90DC-1B00DA8C07F8.png new file mode 100644 index 0000000..82e2169 Binary files /dev/null and b/Obsidian/C016E20E-3F44-4372-90DC-1B00DA8C07F8.png differ diff --git a/Obsidian/icon.png b/Obsidian/icon.png new file mode 100644 index 0000000..82e2169 Binary files /dev/null and b/Obsidian/icon.png differ diff --git a/Obsidian/info.plist b/Obsidian/info.plist new file mode 100644 index 0000000..86d3a31 --- /dev/null +++ b/Obsidian/info.plist @@ -0,0 +1,4616 @@ + + + + + bundleid + com.hauselin.obsidian + category + Productivity + connections + + 08189677-1EA8-4DC2-9C09-DC2F2AF0866E + + + destinationuid + 2C31829D-621E-4707-B16D-5899AE7907FD + modifiers + 0 + modifiersubtext + + vitoclose + + + + 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D + + + destinationuid + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + + + destinationuid + 67E25071-1FF8-4F8B-9A9F-2509093593B6 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 1BD03BB0-06B9-47F5-9346-7A829C38B248 + + + destinationuid + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + modifiers + 0 + modifiersubtext + + vitoclose + + + + 249B0782-BFFB-4382-A857-5058D7C3D244 + + + destinationuid + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 29B3A4DB-80CD-498F-A079-18F1CA7DD20C + + + destinationuid + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + + + destinationuid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 + + + destinationuid + 6290B8D5-ECEB-4623-848B-E5AB92089E79 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + + + destinationuid + 8B221971-0089-4DAC-A056-EC2C961C6EAB + modifiers + 0 + modifiersubtext + + vitoclose + + + + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + + + destinationuid + 73853368-ED10-4729-A4D0-E231647C3CF4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 353B5FD9-BF6A-4635-9AA1-313E16E86B05 + + + destinationuid + 08A7509B-BDA4-455E-A628-38ABF42C04D7 + modifiers + 0 + modifiersubtext + + vitoclose + + + + destinationuid + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 39F0A80F-98F0-47BE-B519-26563D139E54 + + + destinationuid + CDEBE435-E442-4054-80BE-59ADD7EEA597 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3B2DA9A3-761D-467C-BDD7-841584877816 + + + destinationuid + 2C31829D-621E-4707-B16D-5899AE7907FD + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + + + destinationuid + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + + + destinationuid + 6FF78F6F-9167-45D0-B022-7BE55106848C + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3F386808-4E4D-46DE-8331-6B983408DE48 + + + destinationuid + 15356FC5-2D9E-4997-B906-08EEA245D255 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3F7FA866-52E3-46A9-84EE-80A4D3244647 + + + destinationuid + A70B656D-CA4C-41F9-99E3-988FB6158F5F + modifiers + 0 + modifiersubtext + + vitoclose + + + + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 + + + destinationuid + 249B0782-BFFB-4382-A857-5058D7C3D244 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 44D69DBA-085D-4208-86A1-CED1CA068AB3 + + + destinationuid + 46732892-62E0-47CE-B727-EBA967105197 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 46732892-62E0-47CE-B727-EBA967105197 + + + destinationuid + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + modifiers + 0 + modifiersubtext + + vitoclose + + + + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + + + destinationuid + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + + + destinationuid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + + + destinationuid + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + modifiers + 0 + modifiersubtext + + vitoclose + + + + 65DEE317-811D-4787-87B4-3909B62061EA + + + destinationuid + B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + + + destinationuid + 82B5116A-964C-4E76-AA72-45B844D83BEA + modifiers + 0 + modifiersubtext + + vitoclose + + + + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + + + destinationuid + DE762236-EFCC-45D3-85CA-A1B6B191762C + modifiers + 0 + modifiersubtext + + vitoclose + + + + 6FF78F6F-9167-45D0-B022-7BE55106848C + + + destinationuid + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 76C3031F-7B85-45C6-9D05-DF5802BBC167 + + + destinationuid + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 82B5116A-964C-4E76-AA72-45B844D83BEA + + + destinationuid + 39F0A80F-98F0-47BE-B519-26563D139E54 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 834BB1A9-B643-4448-97B4-B6B6582602CB + + + destinationuid + 2754DF89-417E-46D0-A435-3ED58F2CB8CF + modifiers + 0 + modifiersubtext + + vitoclose + + + + 854EB1EE-9017-4F43-BC80-BAF317FC5315 + + + destinationuid + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + + + destinationuid + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 8B221971-0089-4DAC-A056-EC2C961C6EAB + + + destinationuid + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 8C017EEF-38DD-4148-9291-9302EFCE33DE + + + destinationuid + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + modifiers + 0 + modifiersubtext + + vitoclose + + + + 9295060C-B513-4806-8F12-52EC6D30C9A3 + + + destinationuid + 46732892-62E0-47CE-B727-EBA967105197 + modifiers + 0 + modifiersubtext + + vitoclose + + + + A60FCD19-F3A3-4B26-BDB2-52D548E38686 + + + destinationuid + 001B3A3A-722E-440B-AA33-3589A525546C + modifiers + 0 + modifiersubtext + + vitoclose + + + + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 + + + destinationuid + 82B5116A-964C-4E76-AA72-45B844D83BEA + modifiers + 0 + modifiersubtext + + vitoclose + + + + ADAB8847-A309-4A02-9D42-E8D30C47BC5D + + + destinationuid + E6955BE2-FEB7-470D-92BE-03EDF6C498FB + modifiers + 0 + modifiersubtext + + vitoclose + + + + B768A804-C61E-4133-AB9C-74C6448BFC62 + + + destinationuid + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + modifiers + 0 + modifiersubtext + + vitoclose + + + + BDE4BB5C-ECD8-439A-B893-A9C70345010D + + + destinationuid + 001B3A3A-722E-440B-AA33-3589A525546C + modifiers + 0 + modifiersubtext + + vitoclose + + + + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + + + destinationuid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + modifiers + 0 + modifiersubtext + + vitoclose + + + + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + + + destinationuid + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + CEC4065E-BADA-44B7-A255-4A9D613685E2 + + + destinationuid + 249B0782-BFFB-4382-A857-5058D7C3D244 + modifiers + 0 + modifiersubtext + + vitoclose + + + + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 + + + destinationuid + 360748C4-EF05-4FC2-8AB9-E4A969D2D256 + modifiers + 0 + modifiersubtext + + vitoclose + + + + F565051F-71D8-42F7-A733-5DA9F39AAEA2 + + + destinationuid + F8C5232B-3EDC-4388-851E-BFE6602C88D0 + modifiers + 0 + modifiersubtext + + vitoclose + + + + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + + + destinationuid + 6FF78F6F-9167-45D0-B022-7BE55106848C + modifiers + 0 + modifiersubtext + + vitoclose + + + + + createdby + Hause Lin + description + A workflow to open Obsidian vaults, daily note, and search for notes in vaults. + disabled + + name + Obsidian + objects + + + config + + argumenttype + 2 + keyword + od + subtext + + text + Open Obsidian Daily Note + withspace + + + type + alfred.workflow.input.keyword + uid + B768A804-C61E-4133-AB9C-74C6448BFC62 + version + 1 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 31 + hotmod + 1572864 + hotstring + O + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + BDE4BB5C-ECD8-439A-B893-A9C70345010D + version + 2 + + + config + + browser + + spaces + + url + https://forum.obsidian.md/ + utf8 + + + type + alfred.workflow.action.openurl + uid + 08A7509B-BDA4-455E-A628-38ABF42C04D7 + version + 1 + + + config + + paths + + /Applications/Obsidian.app + + toggle + + + type + alfred.workflow.action.launchfiles + uid + 001B3A3A-722E-440B-AA33-3589A525546C + version + 1 + + + config + + argumenttype + 2 + keyword + o? + subtext + Open help and forum pages + text + Obsidian help + withspace + + + type + alfred.workflow.input.keyword + uid + 353B5FD9-BF6A-4635-9AA1-313E16E86B05 + version + 1 + + + config + + concurrently + + escaping + 0 + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script - od') + + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + + +// date format +date_format = $.getenv('dailyformat') +console.log(date_format) + +// vault name +v = $.getenv('dailyvaultname'); +console.log(v) + +// specify the absolute/full path to the directory where you keep your daily notes +fulldir_daily = $.getenv('dailyabspath'); +fulldir_daily = interpolate_homepath(fulldir_daily) +console.log(fulldir_daily) + +// if you have a template for your daily note, specify the absolute/full path to this note +fullpath_template = $.getenv('dailytempabspath'); +fullpath_template = interpolate_homepath(fullpath_template) +console.log(fullpath_template) + + + + + + +var months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] +var months_short = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] + +// https://momentjscom.readthedocs.io/en/latest/moment/07-customization/04-weekday-abbreviations/ +var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] +var days_short = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] +var days_e = [0, 1, 2, 3, 4, 5, 6] +var days_E = [7, 1, 2, 3, 4, 5, 6] + +// get week of year +function ISO8601_week_no(dt) { + var tdt = new Date(dt.valueOf()); + var dayn = (dt.getDay() + 6) % 7; + tdt.setDate(tdt.getDate() - dayn + 3); + var firstThursday = tdt.valueOf(); + tdt.setMonth(0, 1); + if (tdt.getDay() !== 4) { + tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7); + } + return 1 + Math.ceil((firstThursday - tdt) / 604800000); +} + + + + + +// get today's date +today = new Date(); +yyyy = today.getFullYear().toString(); +mm = (today.getMonth() + 1).toString(); +dd = today.getDate().toString(); +ww = ISO8601_week_no(today).toString(); +day = today.getDay() + + + + + + + + + + +date_format_original = date_format; + +// get today's day if requested +if (date_format.includes('dddd')) { + day_string = days[day] + date_format = date_format.replace('dddd', 'zzzz') +} +if (date_format.includes('ddd')) { + day_string_short = days_short[day] + date_format = date_format.replace('ddd', 'zzz') +} + +if (date_format.includes('e')) { + date_format = date_format.replace('e', '!') +} +if (date_format.includes('E')) { + date_format = date_format.replace('E', '@') +} + +date_format = date_format.toLowerCase(); +console.log('original: ' + date_format_original); +console.log('date_format: ' + date_format); + +// determine no. of y, m, d needed +n_y = date_format.split('y').length - 1; +n_m = date_format.split('m').length - 1; +n_d = date_format.split('d').length - 1; +n_w = date_format.split('w').length - 1; + +if (n_y == 0) {n_y = 1}; +if (n_m == 0) {n_m = 1}; +if (n_d == 0) {n_d = 1}; +if (n_w == 0) {n_w = 1}; + + +y_char = "y".repeat(n_y); +m_char = "m".repeat(n_m); +d_char = "d".repeat(n_d); +w_char = "w".repeat(n_w); + +console.log('y_char: ' + y_char); +console.log('m_char: ' + m_char); +console.log('d_char: ' + d_char); +console.log('w_char: ' + w_char); + + +// format date according to user specification (e.g., yy, m, d) +yyyy = yyyy.slice(4-n_y, 4); +if (mm.length == 1) {mm = mm.padStart(2, '0').slice(2-n_m, 2)}; +if (dd.length == 1) {dd = dd.padStart(2, '0').slice(2-n_d, 2)}; +if (ww.length == 1) {ww = ww.padStart(2, '0').slice(2-n_w, 2)}; + +date_format = date_format.replace(y_char, yyyy); +date_format = date_format.replace(m_char, mm); +date_format = date_format.replace(d_char, dd); +date_format = date_format.replace(w_char, ww); + +console.log('2. date_format: ' + date_format); + +// convert to MMM or MMMM +if (m_char == 'mmmm') { + date_format = date_format.replace(mm, months[Number(mm)-1]) +} +if (m_char == 'mmm') { + date_format = date_format.replace(mm, months_short[Number(mm)-1]) +} + +// day of week if requested +if (date_format.includes('zzzz')) { + date_format = date_format.replace('zzzz', day_string) +} +if (date_format.includes('zzz')) { + date_format = date_format.replace('zzz', day_string_short) +} +// e is day of week (0, 1, ... 7) +if (date_format_original.includes('e')) { + date_format = date_format.replace('!', days_e[day].toString()) +} +if (date_format_original.includes('E')) { + date_format = date_format.replace('@', days_E[day].toString()) +} + +console.log('3. date_format: ' + date_format); + +p = encodeURIComponent(v) + "&file=" + date_format + ".md"; +uri = "obsidian://open?vault=" + p; + + +console.log('uri', uri); + +// create new daily note if it doesn't exist +if (fulldir_daily != "") { + // format file path + if (fulldir_daily[(fulldir_daily.length-1)] != "/") {fulldir_daily += "/"} + filepath = fulldir_daily + date_format + ".md" + + console.log('filepath', filepath); + + // get template content + var template_txt = "" + if (fullpath_template != "") { + console.log('fullpath_template', fullpath_template); + var template_path_obj = Path(fullpath_template); + console.log('template_path_obj', template_path_obj) + template_txt = app.read(Path(fullpath_template)) + } + + console.log('template_txt', template_txt); + + // create note with template (if exists) + var path = Path(filepath) + var finderApp = Application("Finder") + if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write(template_txt, { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + uri = "obsidian://open?path=" + encodeURIComponent(filepath) + // wait a bit for note to show up in file system + delay(1) + } +} + + +if (v == "" | date_format == "2111") { + app.displayDialog("Set up the workflow first") +} else { + // open file in vault + app.openLocation(uri); + console.log(uri); +} + + +// save today note path +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", { + toValue: filepath, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +homepath = app.pathTo('home folder') +console.log(homepath) + + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + +// date format +date_format = $.getenv('dailyformat') +console.log(date_format) + +// vault name +v = $.getenv('dailyvaultname'); +console.log(v) + +// specify the absolute/full path to the directory where you keep your daily notes +fulldir_daily = $.getenv('dailyabspath'); +fulldir_daily = interpolate_homepath(fulldir_daily) +console.log(fulldir_daily) + +// if you have a template for your daily note, specify the absolute/full path to this note +fullpath_template = $.getenv('dailytempabspath'); +fullpath_template = interpolate_homepath(fullpath_template) +console.log(fullpath_template) + + + + + + + + + +var months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] +var months_short = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] + +// https://momentjscom.readthedocs.io/en/latest/moment/07-customization/04-weekday-abbreviations/ +var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] +var days_short = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] +var days_e = [0, 1, 2, 3, 4, 5, 6] +var days_E = [7, 1, 2, 3, 4, 5, 6] + +// get week of year +function ISO8601_week_no(dt) { + var tdt = new Date(dt.valueOf()); + var dayn = (dt.getDay() + 6) % 7; + tdt.setDate(tdt.getDate() - dayn + 3); + var firstThursday = tdt.valueOf(); + tdt.setMonth(0, 1); + if (tdt.getDay() !== 4) { + tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7); + } + return 1 + Math.ceil((firstThursday - tdt) / 604800000); +} + + + + +// get today's date +today = new Date() +// get tomorrrow's date +tomorrow = new Date(today) +tomorrow.setDate(tomorrow.getDate() + 1) + +yyyy = tomorrow.getFullYear().toString(); +mm = (tomorrow.getMonth() + 1).toString(); +dd = tomorrow.getDate().toString(); +ww = ISO8601_week_no(tomorrow).toString(); +day = tomorrow.getDay() + + + + + +date_format_original = date_format; + +// get today's day if requested +if (date_format.includes('dddd')) { + day_string = days[day] + date_format = date_format.replace('dddd', 'zzzz') +} +if (date_format.includes('ddd')) { + day_string_short = days_short[day] + date_format = date_format.replace('ddd', 'zzz') +} + +if (date_format.includes('e')) { + date_format = date_format.replace('e', '!') +} +if (date_format.includes('E')) { + date_format = date_format.replace('E', '@') +} + +date_format = date_format.toLowerCase(); +console.log('original: ' + date_format_original); + +// determine no. of y, m, d needed +n_y = date_format.split('y').length - 1; +n_m = date_format.split('m').length - 1; +n_d = date_format.split('d').length - 1; +n_w = date_format.split('w').length - 1; + +if (n_y == 0) {n_y = 1}; +if (n_m == 0) {n_m = 1}; +if (n_d == 0) {n_d = 1}; +if (n_w == 0) {n_w = 1}; + +y_char = "y".repeat(n_y); +m_char = "m".repeat(n_m); +d_char = "d".repeat(n_d); +w_char = "w".repeat(n_w); + +// format date according to user specification (e.g., yy, m, d) +yyyy = yyyy.slice(4-n_y, 4); +if (mm.length == 1) {mm = mm.padStart(2, '0').slice(2-n_m, 2)}; +if (dd.length == 1) {dd = dd.padStart(2, '0').slice(2-n_d, 2)}; +if (ww.length == 1) {ww = ww.padStart(2, '0').slice(2-n_w, 2)}; + +date_format = date_format.replace(y_char, yyyy); +date_format = date_format.replace(m_char, mm); +date_format = date_format.replace(d_char, dd); +date_format = date_format.replace(w_char, ww); + +// convert to MMM or MMMM +if (m_char == 'mmmm') { + date_format = date_format.replace(mm, months[Number(mm)-1]) +} +if (m_char == 'mmm') { + date_format = date_format.replace(mm, months_short[Number(mm)-1]) +} + +// day of week if requested +if (date_format.includes('zzzz')) { + date_format = date_format.replace('zzzz', day_string) +} +if (date_format.includes('zzz')) { + date_format = date_format.replace('zzz', day_string_short) +} +// e is day of week (0, 1, ... 7) +if (date_format_original.includes('e')) { + date_format = date_format.replace('!', days_e[day].toString()) +} +if (date_format_original.includes('E')) { + date_format = date_format.replace('@', days_E[day].toString()) +} + +p = encodeURIComponent(v) + "&file=" + date_format + ".md"; +uri = "obsidian://open?vault=" + p; + +// create new daily note if it doesn't exist +if (fulldir_daily != "") { + // format file path + if (fulldir_daily[(fulldir_daily.length-1)] != "/") {fulldir_daily += "/"} + filepath = fulldir_daily + date_format + ".md" + + // get template content + var template_txt = "" + if (fullpath_template != "") { + template_txt = app.read(Path(fullpath_template)) + } + + // create note with template (if exists) + var path = Path(filepath) + var finderApp = Application("Finder") + if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write(template_txt, { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + uri = "obsidian://open?path=" + encodeURIComponent(filepath) + // wait a bit for note to show up in file system + delay(1) + } +} + + +if (v == "" | date_format == "2111") { + app.displayDialog("Set up the workflow first") +} else { + // open file in vault + app.openLocation(uri); + console.log(uri); +} + + +// save today note path +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", { + toValue: filepath, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 360748C4-EF05-4FC2-8AB9-E4A969D2D256 + version + 2 + + + config + + argumenttype + 2 + keyword + obs + subtext + + text + Open Obsidian + withspace + + + type + alfred.workflow.input.keyword + uid + A60FCD19-F3A3-4B26-BDB2-52D548E38686 + version + 1 + + + config + + argumenttype + 2 + keyword + otmr + subtext + + text + Open tomorrow's Obsidian Daily Note + withspace + + + type + alfred.workflow.input.keyword + uid + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 + version + 1 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 2 + hotmod + 393216 + hotstring + D + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 76C3031F-7B85-45C6-9D05-DF5802BBC167 + version + 2 + + + config + + browser + + spaces + + url + https://publish.obsidian.md/help/Index + utf8 + + + type + alfred.workflow.action.openurl + uid + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + version + 1 + + + config + + argumenttype + 0 + keyword + ov + subtext + Available vaults: obsidian help + text + Open Obsidian {query} Vault + withspace + + + type + alfred.workflow.input.keyword + uid + 29B3A4DB-80CD-498F-A079-18F1CA7DD20C + version + 1 + + + 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 - on') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// get vault name +v="{query}"; + +// construct uri +uri = "obsidian://open?vault=" + encodeURIComponent(v); + +// open +app.openLocation(uri); +console.log(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + version + 2 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + keyword + on + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + Specify which vault to create a new note in + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Specify which vault to create a new note in + title + Create new note in a vault + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 854EB1EE-9017-4F43-BC80-BAF317FC5315 + version + 3 + + + config + + argumenttype + 1 + subtext + {query}.md (default: {var:fname_default}) + text + New note title? + withspace + + + type + alfred.workflow.input.keyword + uid + 8B221971-0089-4DAC-A056-EC2C961C6EAB + version + 1 + + + config + + concurrently + + escaping + 0 + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script - on') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +var v = $.getenv('vault'); +var fname = $.getenv('fname'); + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +if (fname == "") { // use default title + fname = $.getenv('fname_default') +} + +console.log(v) +console.log(fname) + +// get vault path +for (i = 2; i < 1000; i++) { + var vidx = 'vault' + i.toString() + 'name' + var temp = $.getenv(vidx) // throws error if variable doesn't exist + console.log(temp) + if (temp == v) { + var vpath = $.getenv('vault' + i.toString()) + vpath = interpolate_homepath(vpath) + console.log('vpath: ' + vpath) + break + } +} + +var filepath = vpath + "/" + fname + ".md"; +console.log("filepath: " + filepath) + +// create file +var path = Path(filepath) +var finderApp = Application("Finder") +if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write("", { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + delay(1) +} + +// open file +// construct uri +uri = "obsidian://open?vault=" + encodeURIComponent(v) + "&file=" + encodeURIComponent(fname); + +// open file in vault +app.openLocation(uri); +console.log(uri); + +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + version + 2 + + + config + + argument + + passthroughargument + + variables + + fname + {query} + + + type + alfred.workflow.utility.argument + uid + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + version + 1 + + + config + + argument + + passthroughargument + + variables + + fname_default + {date:yyyyMMdd_HHmmss} + vault + {query} + + + type + alfred.workflow.utility.argument + uid + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + version + 1 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + keyword + oo + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 1; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Which vault to open? + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + version + 3 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script - fallback search') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +var v = $.getenv('vault'); +var fname = $.getenv('fname'); + +// construct uri +uri = "obsidian://search?vault=" + encodeURIComponent(v) + "&query=" + encodeURIComponent(fname); + +// search in vault +app.openLocation(uri); +console.log(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + DE762236-EFCC-45D3-85CA-A1B6B191762C + version + 2 + + + config + + text + Search Obsidian for {query} + + type + alfred.workflow.trigger.fallback + uid + 1BD03BB0-06B9-47F5-9346-7A829C38B248 + version + 1 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script - retrieve vaults') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Which vault to search in? + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + version + 3 + + + config + + argument + + passthroughargument + + variables + + vault + {query} + + + type + alfred.workflow.utility.argument + uid + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + version + 1 + + + config + + argument + + passthroughargument + + variables + + fname + {query} + + + type + alfred.workflow.utility.argument + uid + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + version + 1 + + + config + + argumenttype + 2 + keyword + oss + subtext + Press enter to continue + text + Search within vaults + withspace + + + type + alfred.workflow.input.keyword + uid + 44D69DBA-085D-4208-86A1-CED1CA068AB3 + version + 1 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + oaddvault + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search + title + Add an Obsidian vault + types + + public.folder + + withspace + + + type + alfred.workflow.input.filefilter + uid + 3F7FA866-52E3-46A9-84EE-80A4D3244647 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +// get vault name from path +var path = '{query}' +var idx = path.lastIndexOf("/") +var vaultname = path.substring(idx+1) +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating + +try { // loop through existing vault variables + for (i = 1; i < 1000; i++) { + var vidx = 'vault' + i.toString() + var temp = $.getenv(vidx) // throws error if variable doesn't exist + if (temp == "") { // throws error if variable exists but doesn't have value + throw "catch" + } else { + vaultpaths.push(temp) + } + } +} catch { // create new variable if doesn't exist + + if (!vaultpaths.includes(path)) { // add vault variable only vault hasn't been added + // store vault path + console.log('Assigned ' + vaultname + ' to ' + vidx) + Application('com.runningwithcrayons.Alfred').setConfiguration(vidx, { + toValue: path, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + + // store vault name + Application('com.runningwithcrayons.Alfred').setConfiguration(vidx + "name", { + toValue: vaultname, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + } + +} + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + A70B656D-CA4C-41F9-99E3-988FB6158F5F + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 46732892-62E0-47CE-B727-EBA967105197 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + os + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files + types + + net.daringfireball.markdown + net.ia.markdown + public.plain-text + + withspace + + + type + alfred.workflow.input.filefilter + uid + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 9295060C-B513-4806-8F12-52EC6D30C9A3 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +// get vault name from path +var path = '{query}' +var idx = path.lastIndexOf("/") +var vaultname = path.substring(idx+1) + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyvault", { + toValue: path, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyvaultname", { + toValue: vaultname, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + E6955BE2-FEB7-470D-92BE-03EDF6C498FB + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + odailyvault + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search (current: {var:dailyvaultname}) + title + Specify daily note vault + types + + public.folder + + withspace + + + type + alfred.workflow.input.filefilter + uid + ADAB8847-A309-4A02-9D42-E8D30C47BC5D + version + 2 + + + config + + argumenttype + 2 + keyword + orr + subtext + Press enter to continue + text + Search within vaults (modified last 3 days) + withspace + + + type + alfred.workflow.input.keyword + uid + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 + version + 1 + + + config + + argumenttype + 0 + keyword + odailyformat + subtext + Examples: yyyy-mm-dd, mddyyyy, dd_MMM_yyyy (current: {var:dailyformat}) + text + Specify daily note format: {query} + withspace + + + type + alfred.workflow.input.keyword + uid + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyformat", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + version + 2 + + + config + + concurrently + + escaping + 0 + script + /* cSpell:disable */ +ObjC.import('stdlib'); +console.log('Running script - search') + +// absolute file path to file +p="{query}"; + +// construct uri +uri = "obsidian://open?path=" + encodeURIComponent(p); +console.log(uri) + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// open file in vault +// app.openLocation(uri); +console.log(p); + + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + + +// check if file path contains vault names; if not, append "file://" to it to open in default app +// get all vaults +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + vpath = interpolate_homepath(vpath); + + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +console.log(vaultpaths) + +var invault = 0 +for (i=0; i<vaultpaths.length; i++) { + if (p.indexOf(vaultpaths[i]) >= 0) { + invault = 1 + } +} + +if (invault == 0) { + uri = uri.replace("obsidian://open?path=", "file:///") +} + +app.openLocation(uri); +console.log(uri); +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 249B0782-BFFB-4382-A857-5058D7C3D244 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 2 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + or + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files (modified last 3 days) + types + + net.daringfireball.markdown + net.ia.markdown + public.plain-text + + withspace + + + type + alfred.workflow.input.filefilter + uid + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + CEC4065E-BADA-44B7-A255-4A9D613685E2 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + odailytemplate + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search (current: {var:dailytempabspath}) + title + Specify daily note template + types + + withspace + + + type + alfred.workflow.input.filefilter + uid + F565051F-71D8-42F7-A733-5DA9F39AAEA2 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytempabspath", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + F8C5232B-3EDC-4388-851E-BFE6602C88D0 + version + 2 + + + config + + argumenttype + 2 + keyword + ott + subtext + Press enter to continue + text + Search within vaults (modified today) + withspace + + + type + alfred.workflow.input.keyword + uid + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + odailypath + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search (current: {var:dailyabspath}) + title + Specify daily note directory + types + + public.folder + + withspace + + + type + alfred.workflow.input.filefilter + uid + 8C017EEF-38DD-4148-9291-9302EFCE33DE + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 1 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + ot + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files (modified today) + types + + net.daringfireball.markdown + net.ia.markdown + public.plain-text + + withspace + + + type + alfred.workflow.input.filefilter + uid + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 6FF78F6F-9167-45D0-B022-7BE55106848C + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + version + 2 + + + config + + argumenttype + 2 + keyword + oclearvaults + subtext + Clears all but Obsidian help vault + text + Clear all vaults + withspace + + + type + alfred.workflow.input.keyword + uid + 834BB1A9-B643-4448-97B4-B6B6582602CB + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +try { // loop through existing vault variables + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx, { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + } +} catch { + console.log("Removed " + (i-1).toString() + " variables"); +} + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 2754DF89-417E-46D0-A435-3ED58F2CB8CF + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +var remove_vault = '{query}'; +console.log(remove_vault) + +try { // loop through existing vault variables + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + vname = $.getenv(vidx + 'name') + if (vname == remove_vault) { + console.log("Found vault. Clearing it.") + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx, { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + break + } + } +} catch { + console.log("Vault not found."); +} + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 67E25071-1FF8-4F8B-9A9F-2509093593B6 + version + 2 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 0 + escaping + 68 + keyword + oclearvault + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: "Clear vault: " + vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Clear one vault + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + 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 + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + keyword + oterm + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 1; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vpath, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Which vault to open in bash? + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 3F386808-4E4D-46DE-8331-6B983408DE48 + version + 3 + + + config + + argumenttype + 0 + keyword + odailyheader + subtext + Examples: # Log, ## Inbox + text + Specify header to append to: {query} + withspace + + + type + alfred.workflow.input.keyword + uid + 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyheader", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 + version + 2 + + + config + + argumenttype + 0 + keyword + oi + subtext + Append to the end of inbox note: {query} + text + Append text to an inbox note + withspace + + + type + alfred.workflow.input.keyword + uid + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + version + 1 + + + config + + concurrently + + escaping + 68 + script + /* cSpell:disable */ +ObjC.import('stdlib'); +console.log('Running script: oi') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +// get inbox note path +var inbox_md = $.getenv('inbox_md'); +inbox_md = interpolate_homepath(inbox_md) + +// escape " +var query = "{query}"; +// query = query.replaceAll('"', '\"'); +query = query.replace(/\"/g, '\"'); // github #25 @jamiew + +// 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 + + type + 7 + + type + alfred.workflow.action.script + uid + CDEBE435-E442-4054-80BE-59ADD7EEA597 + version + 2 + + + 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 + + matchmode + 0 + matchstring + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + 39F0A80F-98F0-47BE-B519-26563D139E54 + version + 2 + + + config + + matchmode + 0 + matchstring + + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + 82B5116A-964C-4E76-AA72-45B844D83BEA + version + 2 + + + config + + action + 0 + argument + 2 + focusedappvariable + + focusedappvariablename + + hotkey + 34 + hotmod + 1835008 + hotstring + I + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 73853368-ED10-4729-A4D0-E231647C3CF4 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + oinbox + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search + title + Specify inbox markdown + types + + withspace + + + type + alfred.workflow.input.filefilter + uid + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 3B2DA9A3-761D-467C-BDD7-841584877816 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script - oinotify') + + +// get current setting +var oinotify = $.getenv('oinotify'); +console.log('current value: ' + oinotify) + +var title_text = 'Toggle notification' + +// new value +if (oinotify == 'on') { + oinotify = 'off' + var text = 'Disabled notifications' +} else { + oinotify = 'on' + var text = 'Enabled notifications' +} + +// change value +Application('com.runningwithcrayons.Alfred').setConfiguration("oinotify", { + toValue: oinotify, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); +console.log('new value: ' + oinotify) + + + + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; +app.displayNotification(text, {withTitle: title_text}) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 6290B8D5-ECEB-4623-848B-E5AB92089E79 + version + 2 + + + config + + argumenttype + 2 + keyword + oinotify + subtext + + text + Toggle notifications when adding text to inbox note. + withspace + + + type + alfred.workflow.input.keyword + uid + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 + version + 1 + + + config + + concurrently + + escaping + 102 + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script: oii') + +const app = Application.currentApplication() +app.includeStandardAdditions = true + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +// get inbox note path +var inbox_md = $.getenv('inbox_md'); +inbox_md = interpolate_homepath(inbox_md); +console.log(inbox_md) + +uri = "obsidian://open?path=" + encodeURIComponent(inbox_md); +console.log(uri) +app.openLocation(uri); +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype + 1 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 2C31829D-621E-4707-B16D-5899AE7907FD + version + 2 + + + config + + argumenttype + 2 + keyword + oii + subtext + + text + Open inbox note + withspace + + + type + alfred.workflow.input.keyword + uid + 08189677-1EA8-4DC2-9C09-DC2F2AF0866E + version + 1 + + + readme + A workflow to open Obsidian vaults, daily note, and search for notes in vaults. Tested in Obsidian 0.11.4. + +=== + +RELEASE NOTES + +Full documentation: https://github.com/hauselin/obsidian-alfred + +v0.3.2 +- New command oterm to open terminal in selected vault directory +- Fix bug with oi query.replaceAll @jamiew #25 + +v0.3.1 +- Bug fix for paths with ~ @lastobelus #17 #24 + +v0.3.0 +- oi now works with special characters. Rewritten oi script completely. #19 #21 +- New command oinotify to toggle notification on/off when adding text with oi. Defaults to on. #21 +- oii to open inbox note or specify a hotkey to open inbox note. +- Temporary fix for Electron bug where notes don't open when Obsidian isn't already running in the background. #23 + +v0.2.6 +- Added oi to append a list item/bullet point to a note. Use oinbox to specify the note to be used as inbox before using oi. You can also specify a hotkey to directly append clipboard contents as bullet ponitsto your inbox note. #19 + +v0.2.5 +- Minor changes to allow ~ in environment variables. #17 + +v0.2.4 +- Accepts W, w, E, e, dddd, ddd datetime format. +- Open the last-opened vault with keyword obs or your hotkey. + +v0.2.3 +- Accepts MMM and MMMM datetime format. +- Clear a single vault with oclearvault + +v0.2.2 +- Opens markdown files in your default editor if os/or/ot finds/tries to open a file that's not in your Obsidian vault. + +v0.2.1 +- Added otmr to create/open daily note for tomorrow. +- os, or, ot no longer requires an extra step to list matching markdown files, but they will now list matching markdown files found *anywhere* and not just inside your vaults; if you want to search only within your vaults, use oss, orr, or ott instead. + +v0.2.0 +- Major and breaking changes. +- Now requires a one-off initial setup to tell the workflow where/what you vaults are etc. Uses workflow environment variables, so your settings will be saved whenever you update/upgrade this workflow to a newer version. +- Set up: oaddvault, odailyvault, odailyformat, odailypath, odailytemplate, oclearvaults +- No longer requires users to manually edit any osascripts or settings within the workflow. +- Fixes the issue of settings not preserving whenever you upgrade to a newer version of this workflow. +- Create new note in vault with keyword on. + +v0.1.5 +- Add fallback search. +- Daily note keyword (od) can create a new daily note that doesn't exist yet (optional feature). See step 3 in osascript. + +v0.1.4 +- Fix bug with daily note (od). + +v0.1.3 +- Now supports paths with special characters (thanks to @hjklapp). +- Uses JXA actions/scripts instead of bash scripts (thanks to @hjklapp). + +v0.1.2 +- new keywords: oo + +v0.1.1 +- new keywords: ov, od, os, or, ot + +## Known bugs + +If the Obsidian app isn't already opened, this workflow will always open the last recently opened vault. This bug is a known issue with Electron apps on MacOS. + uidata + + 001B3A3A-722E-440B-AA33-3589A525546C + + note + Set up: Specify path to Obsidian app. Open Obsidian app. + xpos + 305 + ypos + 80 + + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + + note + Open Obsidian vault. + xpos + 305 + ypos + 360 + + 08189677-1EA8-4DC2-9C09-DC2F2AF0866E + + note + Open inbox note. + xpos + 600 + ypos + 2410 + + 08A7509B-BDA4-455E-A628-38ABF42C04D7 + + xpos + 765 + ypos + 45 + + 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D + + note + Set up: Specify header of daily note to append list items to. + xpos + 145 + ypos + 1700 + + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + + note + Set up: Clear a selected vault. + xpos + 150 + ypos + 1525 + + 15356FC5-2D9E-4997-B906-08EEA245D255 + + note + Open Obsidian vault. + xpos + 875 + ypos + 1600 + + 1BD03BB0-06B9-47F5-9346-7A829C38B248 + + note + Invoked when you search for a keyword that doesn't match a result on your local. + xpos + 1575 + ypos + 470 + + 249B0782-BFFB-4382-A857-5058D7C3D244 + + note + Define scope based on vaults. + xpos + 840 + ypos + 930 + + 2754DF89-417E-46D0-A435-3ED58F2CB8CF + + xpos + 320 + ypos + 1355 + + 29B3A4DB-80CD-498F-A079-18F1CA7DD20C + + note + Edit subtext to remind yourself of your vault names. + xpos + 115 + ypos + 280 + + 2C31829D-621E-4707-B16D-5899AE7907FD + + xpos + 835 + ypos + 2345 + + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + + note + os. Change settings here. + xpos + 1030 + ypos + 605 + + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 + + note + Set up: Turn on/off notifications when adding text to inbox note. + xpos + 160 + ypos + 2270 + + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + + colorindex + 2 + note + Store vault name in variable. Default title can be changed here. + xpos + 835 + ypos + 415 + + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + + note + Set up: Specify markdown file to use as inbox note. + xpos + 150 + ypos + 2075 + + 353B5FD9-BF6A-4635-9AA1-313E16E86B05 + + note + Obsidian help + xpos + 595 + ypos + 95 + + 360748C4-EF05-4FC2-8AB9-E4A969D2D256 + + xpos + 1655 + ypos + 130 + + 39F0A80F-98F0-47BE-B519-26563D139E54 + + note + replace newline + xpos + 920 + ypos + 1895 + + 3B2DA9A3-761D-467C-BDD7-841584877816 + + note + Set up: Specify hotkey to open inbox note. + xpos + 595 + ypos + 2225 + + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + + colorindex + 6 + note + Store file name/title in variable. + xpos + 1095 + ypos + 415 + + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + + note + Open note in Obsidian. + xpos + 1180 + ypos + 385 + + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + + note + Define hotkey to search in vaults. + xpos + 635 + ypos + 1350 + + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + + xpos + 1185 + ypos + 105 + + 3F386808-4E4D-46DE-8331-6B983408DE48 + + note + Open terminal in vault directory. + xpos + 635 + ypos + 1600 + + 3F7FA866-52E3-46A9-84EE-80A4D3244647 + + note + Set up: Add a vault. + xpos + 145 + ypos + 585 + + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 + + note + Search for recent files (default: last 3 days) + xpos + 645 + ypos + 860 + + 44D69DBA-085D-4208-86A1-CED1CA068AB3 + + note + Search for all files. + xpos + 640 + ypos + 570 + + 46732892-62E0-47CE-B727-EBA967105197 + + note + Define scope based on vaults. + xpos + 840 + ypos + 605 + + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + + xpos + 110 + ypos + 440 + + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + + note + or. Change settings here. + xpos + 1025 + ypos + 930 + + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + + note + Set up: Specify daily note format. + xpos + 155 + ypos + 890 + + 6290B8D5-ECEB-4623-848B-E5AB92089E79 + + xpos + 360 + ypos + 2265 + + 65DEE317-811D-4787-87B4-3909B62061EA + + note + Set up: Specify header of daily note to append todos to. + xpos + 155 + ypos + 1870 + + 67E25071-1FF8-4F8B-9A9F-2509093593B6 + + note + Clear vault. + xpos + 325 + ypos + 1520 + + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + + note + Append text to an inbox note. + xpos + 610 + ypos + 1805 + + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + + colorindex + 2 + note + Store vault name in variable. + xpos + 1995 + ypos + 495 + + 6FF78F6F-9167-45D0-B022-7BE55106848C + + note + Define scope based on vaults. + xpos + 815 + ypos + 1230 + + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + + note + Open note in Obsidian. + xpos + 1275 + ypos + 925 + + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + + xpos + 325 + ypos + 1200 + + 73853368-ED10-4729-A4D0-E231647C3CF4 + + xpos + 350 + ypos + 2060 + + 76C3031F-7B85-45C6-9D05-DF5802BBC167 + + note + Daily note. + xpos + 985 + ypos + 170 + + 82B5116A-964C-4E76-AA72-45B844D83BEA + + note + replace newline + xpos + 810 + ypos + 1895 + + 834BB1A9-B643-4448-97B4-B6B6582602CB + + note + Set up: Clear all but help vault. + xpos + 150 + ypos + 1355 + + 854EB1EE-9017-4F43-BC80-BAF317FC5315 + + note + Vault to create new note in. + xpos + 635 + ypos + 380 + + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + + colorindex + 6 + note + Store search query in variable. + xpos + 1750 + ypos + 500 + + 8B221971-0089-4DAC-A056-EC2C961C6EAB + + note + Title of new note. + xpos + 925 + ypos + 385 + + 8C017EEF-38DD-4148-9291-9302EFCE33DE + + note + Set up: Specify daily note directory/path. + xpos + 155 + ypos + 1200 + + 9295060C-B513-4806-8F12-52EC6D30C9A3 + + note + Define hotkey to search in vaults. + xpos + 640 + ypos + 700 + + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + + xpos + 765 + ypos + 180 + + A60FCD19-F3A3-4B26-BDB2-52D548E38686 + + xpos + 120 + ypos + 140 + + A70B656D-CA4C-41F9-99E3-988FB6158F5F + + xpos + 325 + ypos + 585 + + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 + + note + Set up: Specify hotkey to append clipboard contents inbox note. + xpos + 610 + ypos + 1975 + + ADAB8847-A309-4A02-9D42-E8D30C47BC5D + + note + Set up: Specify daily note vault. + xpos + 150 + ypos + 735 + + B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 + + xpos + 350 + ypos + 1865 + + B768A804-C61E-4133-AB9C-74C6448BFC62 + + note + Open/create today's daily note. + xpos + 975 + ypos + 10 + + BDE4BB5C-ECD8-439A-B893-A9C70345010D + + xpos + 120 + ypos + 15 + + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + + note + ot. Change settings here. + xpos + 1020 + ypos + 1230 + + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + + xpos + 1840 + ypos + 470 + + CDEBE435-E442-4054-80BE-59ADD7EEA597 + + note + Append text to end of note as list item. + xpos + 1045 + ypos + 1865 + + CEC4065E-BADA-44B7-A255-4A9D613685E2 + + note + Define hotkey to search in vaults. + xpos + 645 + ypos + 1010 + + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + + xpos + 325 + ypos + 890 + + DE762236-EFCC-45D3-85CA-A1B6B191762C + + note + Open search pane in Obsidian vault. + xpos + 2075 + ypos + 465 + + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 + + xpos + 355 + ypos + 1705 + + E6955BE2-FEB7-470D-92BE-03EDF6C498FB + + xpos + 325 + ypos + 735 + + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 + + note + Open/create tomorrow's daily note. + xpos + 1455 + ypos + 145 + + F565051F-71D8-42F7-A733-5DA9F39AAEA2 + + note + Set up: Specify daily note template. + xpos + 155 + ypos + 1050 + + F8C5232B-3EDC-4388-851E-BFE6602C88D0 + + xpos + 325 + ypos + 1050 + + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + + note + Search for files modified today + xpos + 640 + ypos + 1185 + + + variables + + dailyabspath + + dailyformat + + dailyheader + + dailytempabspath + + dailytodaypath + + dailytodo + + dailyvault + + dailyvaultname + + inbox_md + + oinotify + on + vault1 + obsidian help + vault1name + obsidian help + vault2 + + vault2name + + vault3 + + vault3name + + + variablesdontexport + + vault3name + inbox_md + vault3 + dailyvaultname + vault2 + dailyabspath + dailytodo + vault2name + dailyformat + dailytodaypath + dailytempabspath + dailyvault + dailyheader + + version + 0.3.3 + webaddress + https://github.com/hauselin/obsidian-alfred + + diff --git a/info.plist b/info.plist new file mode 100644 index 0000000..a130de4 --- /dev/null +++ b/info.plist @@ -0,0 +1,4469 @@ + + + + + bundleid + com.hauselin.obsidian + category + Productivity + connections + + 08189677-1EA8-4DC2-9C09-DC2F2AF0866E + + + destinationuid + 2C31829D-621E-4707-B16D-5899AE7907FD + modifiers + 0 + modifiersubtext + + vitoclose + + + + 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D + + + destinationuid + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + + + destinationuid + 67E25071-1FF8-4F8B-9A9F-2509093593B6 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 1BD03BB0-06B9-47F5-9346-7A829C38B248 + + + destinationuid + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + modifiers + 0 + modifiersubtext + + vitoclose + + + + 249B0782-BFFB-4382-A857-5058D7C3D244 + + + destinationuid + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 29B3A4DB-80CD-498F-A079-18F1CA7DD20C + + + destinationuid + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + + + destinationuid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 + + + destinationuid + 6290B8D5-ECEB-4623-848B-E5AB92089E79 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + + + destinationuid + 8B221971-0089-4DAC-A056-EC2C961C6EAB + modifiers + 0 + modifiersubtext + + vitoclose + + + + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + + + destinationuid + 73853368-ED10-4729-A4D0-E231647C3CF4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 353B5FD9-BF6A-4635-9AA1-313E16E86B05 + + + destinationuid + 08A7509B-BDA4-455E-A628-38ABF42C04D7 + modifiers + 0 + modifiersubtext + + vitoclose + + + + destinationuid + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 39F0A80F-98F0-47BE-B519-26563D139E54 + + + destinationuid + CDEBE435-E442-4054-80BE-59ADD7EEA597 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3B2DA9A3-761D-467C-BDD7-841584877816 + + + destinationuid + 2C31829D-621E-4707-B16D-5899AE7907FD + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + + + destinationuid + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + + + destinationuid + 6FF78F6F-9167-45D0-B022-7BE55106848C + modifiers + 0 + modifiersubtext + + vitoclose + + + + 3F7FA866-52E3-46A9-84EE-80A4D3244647 + + + destinationuid + A70B656D-CA4C-41F9-99E3-988FB6158F5F + modifiers + 0 + modifiersubtext + + vitoclose + + + + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 + + + destinationuid + 249B0782-BFFB-4382-A857-5058D7C3D244 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 44D69DBA-085D-4208-86A1-CED1CA068AB3 + + + destinationuid + 46732892-62E0-47CE-B727-EBA967105197 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 46732892-62E0-47CE-B727-EBA967105197 + + + destinationuid + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + modifiers + 0 + modifiersubtext + + vitoclose + + + + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + + + destinationuid + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + + + destinationuid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + + + destinationuid + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + modifiers + 0 + modifiersubtext + + vitoclose + + + + 65DEE317-811D-4787-87B4-3909B62061EA + + + destinationuid + B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + + + destinationuid + 82B5116A-964C-4E76-AA72-45B844D83BEA + modifiers + 0 + modifiersubtext + + vitoclose + + + + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + + + destinationuid + DE762236-EFCC-45D3-85CA-A1B6B191762C + modifiers + 0 + modifiersubtext + + vitoclose + + + + 6FF78F6F-9167-45D0-B022-7BE55106848C + + + destinationuid + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 76C3031F-7B85-45C6-9D05-DF5802BBC167 + + + destinationuid + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 82B5116A-964C-4E76-AA72-45B844D83BEA + + + destinationuid + 39F0A80F-98F0-47BE-B519-26563D139E54 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 834BB1A9-B643-4448-97B4-B6B6582602CB + + + destinationuid + 2754DF89-417E-46D0-A435-3ED58F2CB8CF + modifiers + 0 + modifiersubtext + + vitoclose + + + + 854EB1EE-9017-4F43-BC80-BAF317FC5315 + + + destinationuid + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + + + destinationuid + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 8B221971-0089-4DAC-A056-EC2C961C6EAB + + + destinationuid + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + modifiers + 0 + modifiersubtext + + vitoclose + + + + 8C017EEF-38DD-4148-9291-9302EFCE33DE + + + destinationuid + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + modifiers + 0 + modifiersubtext + + vitoclose + + + + 9295060C-B513-4806-8F12-52EC6D30C9A3 + + + destinationuid + 46732892-62E0-47CE-B727-EBA967105197 + modifiers + 0 + modifiersubtext + + vitoclose + + + + A60FCD19-F3A3-4B26-BDB2-52D548E38686 + + + destinationuid + 001B3A3A-722E-440B-AA33-3589A525546C + modifiers + 0 + modifiersubtext + + vitoclose + + + + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 + + + destinationuid + 82B5116A-964C-4E76-AA72-45B844D83BEA + modifiers + 0 + modifiersubtext + + vitoclose + + + + ADAB8847-A309-4A02-9D42-E8D30C47BC5D + + + destinationuid + E6955BE2-FEB7-470D-92BE-03EDF6C498FB + modifiers + 0 + modifiersubtext + + vitoclose + + + + B768A804-C61E-4133-AB9C-74C6448BFC62 + + + destinationuid + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + modifiers + 0 + modifiersubtext + + vitoclose + + + + BDE4BB5C-ECD8-439A-B893-A9C70345010D + + + destinationuid + 001B3A3A-722E-440B-AA33-3589A525546C + modifiers + 0 + modifiersubtext + + vitoclose + + + + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + + + destinationuid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + modifiers + 0 + modifiersubtext + + vitoclose + + + + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + + + destinationuid + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + modifiers + 0 + modifiersubtext + + vitoclose + + + + CEC4065E-BADA-44B7-A255-4A9D613685E2 + + + destinationuid + 249B0782-BFFB-4382-A857-5058D7C3D244 + modifiers + 0 + modifiersubtext + + vitoclose + + + + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 + + + destinationuid + 360748C4-EF05-4FC2-8AB9-E4A969D2D256 + modifiers + 0 + modifiersubtext + + vitoclose + + + + F565051F-71D8-42F7-A733-5DA9F39AAEA2 + + + destinationuid + F8C5232B-3EDC-4388-851E-BFE6602C88D0 + modifiers + 0 + modifiersubtext + + vitoclose + + + + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + + + destinationuid + 6FF78F6F-9167-45D0-B022-7BE55106848C + modifiers + 0 + modifiersubtext + + vitoclose + + + + + createdby + Hause Lin + description + A workflow to open Obsidian vaults, daily note, and search for notes in vaults. + disabled + + name + Obsidian + objects + + + config + + argumenttype + 2 + keyword + od + subtext + + text + Open Obsidian Daily Note + withspace + + + type + alfred.workflow.input.keyword + uid + B768A804-C61E-4133-AB9C-74C6448BFC62 + version + 1 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 31 + hotmod + 1572864 + hotstring + O + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + BDE4BB5C-ECD8-439A-B893-A9C70345010D + version + 2 + + + config + + browser + + spaces + + url + https://forum.obsidian.md/ + utf8 + + + type + alfred.workflow.action.openurl + uid + 08A7509B-BDA4-455E-A628-38ABF42C04D7 + version + 1 + + + config + + paths + + /Applications/Obsidian.app + + toggle + + + type + alfred.workflow.action.launchfiles + uid + 001B3A3A-722E-440B-AA33-3589A525546C + version + 1 + + + config + + argumenttype + 2 + keyword + o? + subtext + Open help and forum pages + text + Obsidian help + withspace + + + type + alfred.workflow.input.keyword + uid + 353B5FD9-BF6A-4635-9AA1-313E16E86B05 + version + 1 + + + config + + concurrently + + escaping + 0 + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script - od') + + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + + +// date format +date_format = $.getenv('dailyformat') +console.log(date_format) + +// vault name +v = $.getenv('dailyvaultname'); +console.log(v) + +// specify the absolute/full path to the directory where you keep your daily notes +fulldir_daily = $.getenv('dailyabspath'); +fulldir_daily = interpolate_homepath(fulldir_daily) +console.log(fulldir_daily) + +// if you have a template for your daily note, specify the absolute/full path to this note +fullpath_template = $.getenv('dailytempabspath'); +fullpath_template = interpolate_homepath(fullpath_template) +console.log(fullpath_template) + + + + + + +var months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] +var months_short = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] + +// https://momentjscom.readthedocs.io/en/latest/moment/07-customization/04-weekday-abbreviations/ +var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] +var days_short = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] +var days_e = [0, 1, 2, 3, 4, 5, 6] +var days_E = [7, 1, 2, 3, 4, 5, 6] + +// get week of year +function ISO8601_week_no(dt) { + var tdt = new Date(dt.valueOf()); + var dayn = (dt.getDay() + 6) % 7; + tdt.setDate(tdt.getDate() - dayn + 3); + var firstThursday = tdt.valueOf(); + tdt.setMonth(0, 1); + if (tdt.getDay() !== 4) { + tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7); + } + return 1 + Math.ceil((firstThursday - tdt) / 604800000); +} + + + + + +// get today's date +today = new Date(); +yyyy = today.getFullYear().toString(); +mm = (today.getMonth() + 1).toString(); +dd = today.getDate().toString(); +ww = ISO8601_week_no(today).toString(); +day = today.getDay() + + + + + + + + + + +date_format_original = date_format; + +// get today's day if requested +if (date_format.includes('dddd')) { + day_string = days[day] + date_format = date_format.replace('dddd', 'zzzz') +} +if (date_format.includes('ddd')) { + day_string_short = days_short[day] + date_format = date_format.replace('ddd', 'zzz') +} + +if (date_format.includes('e')) { + date_format = date_format.replace('e', '!') +} +if (date_format.includes('E')) { + date_format = date_format.replace('E', '@') +} + +date_format = date_format.toLowerCase(); +console.log('original: ' + date_format_original); +console.log('date_format: ' + date_format); + +// determine no. of y, m, d needed +n_y = date_format.split('y').length - 1; +n_m = date_format.split('m').length - 1; +n_d = date_format.split('d').length - 1; +n_w = date_format.split('w').length - 1; + +if (n_y == 0) {n_y = 1}; +if (n_m == 0) {n_m = 1}; +if (n_d == 0) {n_d = 1}; +if (n_w == 0) {n_w = 1}; + + +y_char = "y".repeat(n_y); +m_char = "m".repeat(n_m); +d_char = "d".repeat(n_d); +w_char = "w".repeat(n_w); + +console.log('y_char: ' + y_char); +console.log('m_char: ' + m_char); +console.log('d_char: ' + d_char); +console.log('w_char: ' + w_char); + + +// format date according to user specification (e.g., yy, m, d) +yyyy = yyyy.slice(4-n_y, 4); +if (mm.length == 1) {mm = mm.padStart(2, '0').slice(2-n_m, 2)}; +if (dd.length == 1) {dd = dd.padStart(2, '0').slice(2-n_d, 2)}; +if (ww.length == 1) {ww = ww.padStart(2, '0').slice(2-n_w, 2)}; + +date_format = date_format.replace(y_char, yyyy); +date_format = date_format.replace(m_char, mm); +date_format = date_format.replace(d_char, dd); +date_format = date_format.replace(w_char, ww); + +console.log('2. date_format: ' + date_format); + +// convert to MMM or MMMM +if (m_char == 'mmmm') { + date_format = date_format.replace(mm, months[Number(mm)-1]) +} +if (m_char == 'mmm') { + date_format = date_format.replace(mm, months_short[Number(mm)-1]) +} + +// day of week if requested +if (date_format.includes('zzzz')) { + date_format = date_format.replace('zzzz', day_string) +} +if (date_format.includes('zzz')) { + date_format = date_format.replace('zzz', day_string_short) +} +// e is day of week (0, 1, ... 7) +if (date_format_original.includes('e')) { + date_format = date_format.replace('!', days_e[day].toString()) +} +if (date_format_original.includes('E')) { + date_format = date_format.replace('@', days_E[day].toString()) +} + +console.log('3. date_format: ' + date_format); + +p = encodeURIComponent(v) + "&file=" + date_format + ".md"; +uri = "obsidian://open?vault=" + p; + + +console.log('uri', uri); + +// create new daily note if it doesn't exist +if (fulldir_daily != "") { + // format file path + if (fulldir_daily[(fulldir_daily.length-1)] != "/") {fulldir_daily += "/"} + filepath = fulldir_daily + date_format + ".md" + + console.log('filepath', filepath); + + // get template content + var template_txt = "" + if (fullpath_template != "") { + console.log('fullpath_template', fullpath_template); + var template_path_obj = Path(fullpath_template); + console.log('template_path_obj', template_path_obj) + template_txt = app.read(Path(fullpath_template)) + } + + console.log('template_txt', template_txt); + + // create note with template (if exists) + var path = Path(filepath) + var finderApp = Application("Finder") + if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write(template_txt, { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + uri = "obsidian://open?path=" + encodeURIComponent(filepath) + // wait a bit for note to show up in file system + delay(1) + } +} + + +if (v == "" | date_format == "2111") { + app.displayDialog("Set up the workflow first") +} else { + // open file in vault + app.openLocation(uri); + console.log(uri); +} + + +// save today note path +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", { + toValue: filepath, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +homepath = app.pathTo('home folder') +console.log(homepath) + + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + +// date format +date_format = $.getenv('dailyformat') +console.log(date_format) + +// vault name +v = $.getenv('dailyvaultname'); +console.log(v) + +// specify the absolute/full path to the directory where you keep your daily notes +fulldir_daily = $.getenv('dailyabspath'); +fulldir_daily = interpolate_homepath(fulldir_daily) +console.log(fulldir_daily) + +// if you have a template for your daily note, specify the absolute/full path to this note +fullpath_template = $.getenv('dailytempabspath'); +fullpath_template = interpolate_homepath(fullpath_template) +console.log(fullpath_template) + + + + + + + + + +var months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] +var months_short = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] + +// https://momentjscom.readthedocs.io/en/latest/moment/07-customization/04-weekday-abbreviations/ +var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] +var days_short = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] +var days_e = [0, 1, 2, 3, 4, 5, 6] +var days_E = [7, 1, 2, 3, 4, 5, 6] + +// get week of year +function ISO8601_week_no(dt) { + var tdt = new Date(dt.valueOf()); + var dayn = (dt.getDay() + 6) % 7; + tdt.setDate(tdt.getDate() - dayn + 3); + var firstThursday = tdt.valueOf(); + tdt.setMonth(0, 1); + if (tdt.getDay() !== 4) { + tdt.setMonth(0, 1 + ((4 - tdt.getDay()) + 7) % 7); + } + return 1 + Math.ceil((firstThursday - tdt) / 604800000); +} + + + + +// get today's date +today = new Date() +// get tomorrrow's date +tomorrow = new Date(today) +tomorrow.setDate(tomorrow.getDate() + 1) + +yyyy = tomorrow.getFullYear().toString(); +mm = (tomorrow.getMonth() + 1).toString(); +dd = tomorrow.getDate().toString(); +ww = ISO8601_week_no(tomorrow).toString(); +day = tomorrow.getDay() + + + + + +date_format_original = date_format; + +// get today's day if requested +if (date_format.includes('dddd')) { + day_string = days[day] + date_format = date_format.replace('dddd', 'zzzz') +} +if (date_format.includes('ddd')) { + day_string_short = days_short[day] + date_format = date_format.replace('ddd', 'zzz') +} + +if (date_format.includes('e')) { + date_format = date_format.replace('e', '!') +} +if (date_format.includes('E')) { + date_format = date_format.replace('E', '@') +} + +date_format = date_format.toLowerCase(); +console.log('original: ' + date_format_original); + +// determine no. of y, m, d needed +n_y = date_format.split('y').length - 1; +n_m = date_format.split('m').length - 1; +n_d = date_format.split('d').length - 1; +n_w = date_format.split('w').length - 1; + +if (n_y == 0) {n_y = 1}; +if (n_m == 0) {n_m = 1}; +if (n_d == 0) {n_d = 1}; +if (n_w == 0) {n_w = 1}; + +y_char = "y".repeat(n_y); +m_char = "m".repeat(n_m); +d_char = "d".repeat(n_d); +w_char = "w".repeat(n_w); + +// format date according to user specification (e.g., yy, m, d) +yyyy = yyyy.slice(4-n_y, 4); +if (mm.length == 1) {mm = mm.padStart(2, '0').slice(2-n_m, 2)}; +if (dd.length == 1) {dd = dd.padStart(2, '0').slice(2-n_d, 2)}; +if (ww.length == 1) {ww = ww.padStart(2, '0').slice(2-n_w, 2)}; + +date_format = date_format.replace(y_char, yyyy); +date_format = date_format.replace(m_char, mm); +date_format = date_format.replace(d_char, dd); +date_format = date_format.replace(w_char, ww); + +// convert to MMM or MMMM +if (m_char == 'mmmm') { + date_format = date_format.replace(mm, months[Number(mm)-1]) +} +if (m_char == 'mmm') { + date_format = date_format.replace(mm, months_short[Number(mm)-1]) +} + +// day of week if requested +if (date_format.includes('zzzz')) { + date_format = date_format.replace('zzzz', day_string) +} +if (date_format.includes('zzz')) { + date_format = date_format.replace('zzz', day_string_short) +} +// e is day of week (0, 1, ... 7) +if (date_format_original.includes('e')) { + date_format = date_format.replace('!', days_e[day].toString()) +} +if (date_format_original.includes('E')) { + date_format = date_format.replace('@', days_E[day].toString()) +} + +p = encodeURIComponent(v) + "&file=" + date_format + ".md"; +uri = "obsidian://open?vault=" + p; + +// create new daily note if it doesn't exist +if (fulldir_daily != "") { + // format file path + if (fulldir_daily[(fulldir_daily.length-1)] != "/") {fulldir_daily += "/"} + filepath = fulldir_daily + date_format + ".md" + + // get template content + var template_txt = "" + if (fullpath_template != "") { + template_txt = app.read(Path(fullpath_template)) + } + + // create note with template (if exists) + var path = Path(filepath) + var finderApp = Application("Finder") + if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write(template_txt, { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + uri = "obsidian://open?path=" + encodeURIComponent(filepath) + // wait a bit for note to show up in file system + delay(1) + } +} + + +if (v == "" | date_format == "2111") { + app.displayDialog("Set up the workflow first") +} else { + // open file in vault + app.openLocation(uri); + console.log(uri); +} + + +// save today note path +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytodaypath", { + toValue: filepath, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 360748C4-EF05-4FC2-8AB9-E4A969D2D256 + version + 2 + + + config + + argumenttype + 2 + keyword + obs + subtext + + text + Open Obsidian + withspace + + + type + alfred.workflow.input.keyword + uid + A60FCD19-F3A3-4B26-BDB2-52D548E38686 + version + 1 + + + config + + argumenttype + 2 + keyword + otmr + subtext + + text + Open tomorrow's Obsidian Daily Note + withspace + + + type + alfred.workflow.input.keyword + uid + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 + version + 1 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 2 + hotmod + 393216 + hotstring + D + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 76C3031F-7B85-45C6-9D05-DF5802BBC167 + version + 2 + + + config + + browser + + spaces + + url + https://publish.obsidian.md/help/Index + utf8 + + + type + alfred.workflow.action.openurl + uid + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + version + 1 + + + config + + argumenttype + 0 + keyword + ov + subtext + Available vaults: obsidian help + text + Open Obsidian {query} Vault + withspace + + + type + alfred.workflow.input.keyword + uid + 29B3A4DB-80CD-498F-A079-18F1CA7DD20C + version + 1 + + + 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 - on') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// get vault name +v="{query}"; + +// construct uri +uri = "obsidian://open?vault=" + encodeURIComponent(v); + +// open +app.openLocation(uri); +console.log(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + version + 2 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + keyword + on + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + Specify which vault to create a new note in + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Specify which vault to create a new note in + title + Create new note in a vault + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 854EB1EE-9017-4F43-BC80-BAF317FC5315 + version + 3 + + + config + + argumenttype + 1 + subtext + {query}.md (default: {var:fname_default}) + text + New note title? + withspace + + + type + alfred.workflow.input.keyword + uid + 8B221971-0089-4DAC-A056-EC2C961C6EAB + version + 1 + + + config + + concurrently + + escaping + 0 + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script - on') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +var v = $.getenv('vault'); +var fname = $.getenv('fname'); + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +if (fname == "") { // use default title + fname = $.getenv('fname_default') +} + +console.log(v) +console.log(fname) + +// get vault path +for (i = 2; i < 1000; i++) { + var vidx = 'vault' + i.toString() + 'name' + var temp = $.getenv(vidx) // throws error if variable doesn't exist + console.log(temp) + if (temp == v) { + var vpath = $.getenv('vault' + i.toString()) + vpath = interpolate_homepath(vpath) + console.log('vpath: ' + vpath) + break + } +} + +var filepath = vpath + "/" + fname + ".md"; +console.log("filepath: " + filepath) + +// create file +var path = Path(filepath) +var finderApp = Application("Finder") +if (!finderApp.exists(path)) { + console.log("Note doesn't exist. Creating note.") + var openedFile = app.openForAccess(path, {writePermission: true}) + app.write("", { to: openedFile, startingAt: app.getEof(openedFile) }) + app.closeAccess(openedFile) + delay(1) +} + +// open file +// construct uri +uri = "obsidian://open?vault=" + encodeURIComponent(v) + "&file=" + encodeURIComponent(fname); + +// open file in vault +app.openLocation(uri); +console.log(uri); + +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + version + 2 + + + config + + argument + + passthroughargument + + variables + + fname + {query} + + + type + alfred.workflow.utility.argument + uid + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + version + 1 + + + config + + argument + + passthroughargument + + variables + + fname_default + {date:yyyyMMdd_HHmmss} + vault + {query} + + + type + alfred.workflow.utility.argument + uid + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + version + 1 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + keyword + oo + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 1; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Which vault to open? + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + version + 3 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script - fallback search') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +var v = $.getenv('vault'); +var fname = $.getenv('fname'); + +// construct uri +uri = "obsidian://search?vault=" + encodeURIComponent(v) + "&query=" + encodeURIComponent(fname); + +// search in vault +app.openLocation(uri); +console.log(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + DE762236-EFCC-45D3-85CA-A1B6B191762C + version + 2 + + + config + + text + Search Obsidian for {query} + + type + alfred.workflow.trigger.fallback + uid + 1BD03BB0-06B9-47F5-9346-7A829C38B248 + version + 1 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 68 + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script - retrieve vaults') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Which vault to search in? + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + version + 3 + + + config + + argument + + passthroughargument + + variables + + vault + {query} + + + type + alfred.workflow.utility.argument + uid + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + version + 1 + + + config + + argument + + passthroughargument + + variables + + fname + {query} + + + type + alfred.workflow.utility.argument + uid + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + version + 1 + + + config + + argumenttype + 2 + keyword + oss + subtext + Press enter to continue + text + Search within vaults + withspace + + + type + alfred.workflow.input.keyword + uid + 44D69DBA-085D-4208-86A1-CED1CA068AB3 + version + 1 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + oaddvault + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search + title + Add an Obsidian vault + types + + public.folder + + withspace + + + type + alfred.workflow.input.filefilter + uid + 3F7FA866-52E3-46A9-84EE-80A4D3244647 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +// get vault name from path +var path = '{query}' +var idx = path.lastIndexOf("/") +var vaultname = path.substring(idx+1) +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating + +try { // loop through existing vault variables + for (i = 1; i < 1000; i++) { + var vidx = 'vault' + i.toString() + var temp = $.getenv(vidx) // throws error if variable doesn't exist + if (temp == "") { // throws error if variable exists but doesn't have value + throw "catch" + } else { + vaultpaths.push(temp) + } + } +} catch { // create new variable if doesn't exist + + if (!vaultpaths.includes(path)) { // add vault variable only vault hasn't been added + // store vault path + console.log('Assigned ' + vaultname + ' to ' + vidx) + Application('com.runningwithcrayons.Alfred').setConfiguration(vidx, { + toValue: path, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + + // store vault name + Application('com.runningwithcrayons.Alfred').setConfiguration(vidx + "name", { + toValue: vaultname, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + } + +} + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + A70B656D-CA4C-41F9-99E3-988FB6158F5F + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 46732892-62E0-47CE-B727-EBA967105197 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + os + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files + types + + net.daringfireball.markdown + net.ia.markdown + public.plain-text + + withspace + + + type + alfred.workflow.input.filefilter + uid + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 9295060C-B513-4806-8F12-52EC6D30C9A3 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +// get vault name from path +var path = '{query}' +var idx = path.lastIndexOf("/") +var vaultname = path.substring(idx+1) + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyvault", { + toValue: path, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyvaultname", { + toValue: vaultname, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + E6955BE2-FEB7-470D-92BE-03EDF6C498FB + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + odailyvault + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search (current: {var:dailyvaultname}) + title + Specify daily note vault + types + + public.folder + + withspace + + + type + alfred.workflow.input.filefilter + uid + ADAB8847-A309-4A02-9D42-E8D30C47BC5D + version + 2 + + + config + + argumenttype + 2 + keyword + orr + subtext + Press enter to continue + text + Search within vaults (modified last 3 days) + withspace + + + type + alfred.workflow.input.keyword + uid + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 + version + 1 + + + config + + argumenttype + 0 + keyword + odailyformat + subtext + Examples: yyyy-mm-dd, mddyyyy, dd_MMM_yyyy (current: {var:dailyformat}) + text + Specify daily note format: {query} + withspace + + + type + alfred.workflow.input.keyword + uid + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyformat", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + version + 2 + + + config + + concurrently + + escaping + 0 + script + /* cSpell:disable */ +ObjC.import('stdlib'); +console.log('Running script - search') + +// absolute file path to file +p="{query}"; + +// construct uri +uri = "obsidian://open?path=" + encodeURIComponent(p); +console.log(uri) + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +// open file in vault +// app.openLocation(uri); +console.log(p); + + + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + + + +// check if file path contains vault names; if not, append "file://" to it to open in default app +// get all vaults +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + vpath = interpolate_homepath(vpath); + + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +console.log(vaultpaths) + +var invault = 0 +for (i=0; i<vaultpaths.length; i++) { + if (p.indexOf(vaultpaths[i]) >= 0) { + invault = 1 + } +} + +if (invault == 0) { + uri = uri.replace("obsidian://open?path=", "file:///") +} + +app.openLocation(uri); +console.log(uri); +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 249B0782-BFFB-4382-A857-5058D7C3D244 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 2 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + or + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files (modified last 3 days) + types + + net.daringfireball.markdown + net.ia.markdown + public.plain-text + + withspace + + + type + alfred.workflow.input.filefilter + uid + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + CEC4065E-BADA-44B7-A255-4A9D613685E2 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + odailytemplate + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search (current: {var:dailytempabspath}) + title + Specify daily note template + types + + withspace + + + type + alfred.workflow.input.filefilter + uid + F565051F-71D8-42F7-A733-5DA9F39AAEA2 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailytempabspath", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + F8C5232B-3EDC-4388-851E-BFE6602C88D0 + version + 2 + + + config + + argumenttype + 2 + keyword + ott + subtext + Press enter to continue + text + Search within vaults (modified today) + withspace + + + type + alfred.workflow.input.keyword + uid + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyabspath", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + odailypath + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search (current: {var:dailyabspath}) + title + Specify daily note directory + types + + public.folder + + withspace + + + type + alfred.workflow.input.filefilter + uid + 8C017EEF-38DD-4148-9291-9302EFCE33DE + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 1 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + ot + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Search for {query} + title + Search markdown files (modified today) + types + + net.daringfireball.markdown + net.ia.markdown + public.plain-text + + withspace + + + type + alfred.workflow.input.filefilter + uid + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + + +// create json object to pass to next object +var jsonobj = { + "alfredworkflow" : { + "arg" : "{query}", + "config" : { + "scopes" : vaultpaths, + } + } +} + +// pass to next object in workflow +JSON.stringify(jsonobj) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 6FF78F6F-9167-45D0-B022-7BE55106848C + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + version + 2 + + + config + + argumenttype + 2 + keyword + oclearvaults + subtext + Clears all but Obsidian help vault + text + Clear all vaults + withspace + + + type + alfred.workflow.input.keyword + uid + 834BB1A9-B643-4448-97B4-B6B6582602CB + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +try { // loop through existing vault variables + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx, { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + } +} catch { + console.log("Removed " + (i-1).toString() + " variables"); +} + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 2754DF89-417E-46D0-A435-3ED58F2CB8CF + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script') + +var remove_vault = '{query}'; +console.log(remove_vault) + +try { // loop through existing vault variables + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + vname = $.getenv(vidx + 'name') + if (vname == remove_vault) { + console.log("Found vault. Clearing it.") + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx, { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + Application('com.runningwithcrayons.Alfred').removeConfiguration(vidx + 'name', { + inWorkflow: $.getenv('alfred_workflow_bundleid'), + }); + break + } + } +} catch { + console.log("Vault not found."); +} + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 67E25071-1FF8-4F8B-9A9F-2509093593B6 + version + 2 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 0 + escaping + 68 + keyword + oclearvault + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + ObjC.import('stdlib'); +console.log('Running script') + +// get all vaults +var vaults = [] +var vaultpaths = [] // keep track of vaultpaths to prevent duplicating +try { + for (i = 2; i < 100; i++) { + var vidx = 'vault' + i.toString() + var vpath = $.getenv(vidx) + var vname = $.getenv(vidx + 'name') + if (vname == "") { + throw "catch" + } + if (!vaultpaths.includes(vpath)) { // include/list vault only if it doesn't exist yet + vaults.push({title: "Clear vault: " + vname, arg: vname, subtitle: vpath, uid: vpath}) + vaultpaths.push(vpath) + } + } +} catch { + console.log('Found ' + (i-1).toString() + ' vaults') +} + +// list vaults +JSON.stringify({items: vaults}) + scriptargtype + 1 + scriptfile + + subtext + Type something to autcomplete or space to list vaults + title + Clear one vault + type + 7 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + version + 3 + + + config + + argumenttype + 0 + keyword + odailyheader + subtext + Examples: # Log, ## Inbox + text + Specify header to append to: {query} + withspace + + + type + alfred.workflow.input.keyword + uid + 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D + version + 1 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("dailyheader", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 + version + 2 + + + config + + argumenttype + 0 + keyword + oi + subtext + Append to the end of inbox note: {query} + text + Append text to an inbox note + withspace + + + type + alfred.workflow.input.keyword + uid + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + version + 1 + + + config + + concurrently + + escaping + 68 + script + /* cSpell:disable */ +ObjC.import('stdlib'); +console.log('Running script: oi') + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +// get inbox note path +var inbox_md = $.getenv('inbox_md'); +inbox_md = interpolate_homepath(inbox_md) + +// escape " +var query = "{query}"; +query = query.replace(/\"/g, '\"'); + +// 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 + + type + 7 + + type + alfred.workflow.action.script + uid + CDEBE435-E442-4054-80BE-59ADD7EEA597 + version + 2 + + + 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 + + matchmode + 0 + matchstring + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + 39F0A80F-98F0-47BE-B519-26563D139E54 + version + 2 + + + config + + matchmode + 0 + matchstring + + + + replacestring + @NEWLISTITEM@ + + type + alfred.workflow.utility.replace + uid + 82B5116A-964C-4E76-AA72-45B844D83BEA + version + 2 + + + config + + action + 0 + argument + 2 + focusedappvariable + + focusedappvariablename + + hotkey + 34 + hotmod + 1835008 + hotstring + I + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); + +console.log('Running script') + +Application('com.runningwithcrayons.Alfred').setConfiguration("inbox_md", { + toValue: "{query}", + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 73853368-ED10-4729-A4D0-E231647C3CF4 + version + 2 + + + config + + anchorfields + + argumenttrimmode + 0 + argumenttype + 0 + daterange + 0 + fields + + + field + kMDItemDisplayName + not + + split + + value + {query} + words + + + + field + kMDItemFinderComment + not + + split + + value + {query} + words + + + + field + kMDItemTextContent + not + + split + + value + {query} + words + + + + includesystem + + keyword + oinbox + limit + 0 + runningsubtext + + scopes + + sortmode + 0 + subtext + Type to search + title + Specify inbox markdown + types + + withspace + + + type + alfred.workflow.input.filefilter + uid + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + version + 2 + + + config + + action + 0 + argument + 0 + focusedappvariable + + focusedappvariablename + + hotkey + 0 + hotmod + 0 + hotstring + + leftcursor + + modsmode + 0 + relatedAppsMode + 0 + + type + alfred.workflow.trigger.hotkey + uid + 3B2DA9A3-761D-467C-BDD7-841584877816 + version + 2 + + + config + + concurrently + + escaping + 68 + script + ObjC.import('stdlib'); +console.log('Running script - oinotify') + + +// get current setting +var oinotify = $.getenv('oinotify'); +console.log('current value: ' + oinotify) + +var title_text = 'Toggle notification' + +// new value +if (oinotify == 'on') { + oinotify = 'off' + var text = 'Disabled notifications' +} else { + oinotify = 'on' + var text = 'Enabled notifications' +} + +// change value +Application('com.runningwithcrayons.Alfred').setConfiguration("oinotify", { + toValue: oinotify, + exportable: false, + inWorkflow: $.getenv('alfred_workflow_bundleid'), +}); +console.log('new value: ' + oinotify) + + + + +// get the current app to access the standard additions +app = Application.currentApplication(); +app.includeStandardAdditions = true; +app.displayNotification(text, {withTitle: title_text}) + scriptargtype + 0 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 6290B8D5-ECEB-4623-848B-E5AB92089E79 + version + 2 + + + config + + argumenttype + 2 + keyword + oinotify + subtext + + text + Toggle notifications when adding text to inbox note. + withspace + + + type + alfred.workflow.input.keyword + uid + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 + version + 1 + + + config + + concurrently + + escaping + 102 + script + /* cSpell:disable */ + +ObjC.import('stdlib'); +console.log('Running script: oii') + +const app = Application.currentApplication() +app.includeStandardAdditions = true + +function interpolate_homepath(path) { + homepath = app.pathTo('home folder') + return path.replace(/^~/, homepath) +} + +// get inbox note path +var inbox_md = $.getenv('inbox_md'); +inbox_md = interpolate_homepath(inbox_md); +console.log(inbox_md) + +uri = "obsidian://open?path=" + encodeURIComponent(inbox_md); +console.log(uri) +app.openLocation(uri); +delay(3.0); // temporary fix for Electron bug (open note twice) +app.openLocation(uri); + scriptargtype + 1 + scriptfile + + type + 7 + + type + alfred.workflow.action.script + uid + 2C31829D-621E-4707-B16D-5899AE7907FD + version + 2 + + + config + + argumenttype + 2 + keyword + oii + subtext + + text + Open inbox note + withspace + + + type + alfred.workflow.input.keyword + uid + 08189677-1EA8-4DC2-9C09-DC2F2AF0866E + version + 1 + + + readme + A workflow to open Obsidian vaults, daily note, and search for notes in vaults. Tested in Obsidian 0.11.4. + +=== + +RELEASE NOTES + +Full documentation: https://github.com/hauselin/obsidian-alfred + +v0.3.1 +- Bug fix for paths with ~ @lastobelus #17 #24 + +v0.3.0 +- oi now works with special characters. Rewritten oi script completely. #19 #21 +- New command oinotify to toggle notification on/off when adding text with oi. Defaults to on. #21 +- oii to open inbox note or specify a hotkey to open inbox note. +- Temporary fix for Electron bug where notes don't open when Obsidian isn't already running in the background. #23 + +v0.2.6 +- Added oi to append a list item/bullet point to a note. Use oinbox to specify the note to be used as inbox before using oi. You can also specify a hotkey to directly append clipboard contents as bullet ponitsto your inbox note. #19 + +v0.2.5 +- Minor changes to allow ~ in environment variables. #17 + +v0.2.4 +- Accepts W, w, E, e, dddd, ddd datetime format. +- Open the last-opened vault with keyword obs or your hotkey. + +v0.2.3 +- Accepts MMM and MMMM datetime format. +- Clear a single vault with oclearvault + +v0.2.2 +- Opens markdown files in your default editor if os/or/ot finds/tries to open a file that's not in your Obsidian vault. + +v0.2.1 +- Added otmr to create/open daily note for tomorrow. +- os, or, ot no longer requires an extra step to list matching markdown files, but they will now list matching markdown files found *anywhere* and not just inside your vaults; if you want to search only within your vaults, use oss, orr, or ott instead. + +v0.2.0 +- Major and breaking changes. +- Now requires a one-off initial setup to tell the workflow where/what you vaults are etc. Uses workflow environment variables, so your settings will be saved whenever you update/upgrade this workflow to a newer version. +- Set up: oaddvault, odailyvault, odailyformat, odailypath, odailytemplate, oclearvaults +- No longer requires users to manually edit any osascripts or settings within the workflow. +- Fixes the issue of settings not preserving whenever you upgrade to a newer version of this workflow. +- Create new note in vault with keyword on. + +v0.1.5 +- Add fallback search. +- Daily note keyword (od) can create a new daily note that doesn't exist yet (optional feature). See step 3 in osascript. + +v0.1.4 +- Fix bug with daily note (od). + +v0.1.3 +- Now supports paths with special characters (thanks to @hjklapp). +- Uses JXA actions/scripts instead of bash scripts (thanks to @hjklapp). + +v0.1.2 +- new keywords: oo + +v0.1.1 +- new keywords: ov, od, os, or, ot + +## Known bugs + +If the Obsidian app isn't already opened, this workflow will always open the last recently opened vault. This bug is a known issue with Electron apps on MacOS. + uidata + + 001B3A3A-722E-440B-AA33-3589A525546C + + note + Set up: Specify path to Obsidian app. Open Obsidian app. + xpos + 305 + ypos + 80 + + 0796CFDE-8B84-4EAD-A82D-6558AF6C4D42 + + note + Open Obsidian vault. + xpos + 305 + ypos + 360 + + 08189677-1EA8-4DC2-9C09-DC2F2AF0866E + + note + Open inbox note. + xpos + 600 + ypos + 2410 + + 08A7509B-BDA4-455E-A628-38ABF42C04D7 + + xpos + 765 + ypos + 45 + + 0EEA412C-D42E-4C94-9C26-077C1CFEFF9D + + note + Set up: Specify header of daily note to append list items to. + xpos + 145 + ypos + 1700 + + 0F2ED3A2-F821-40B0-9915-C8E5E2D84A02 + + note + Set up: Clear a selected vault. + xpos + 150 + ypos + 1525 + + 1BD03BB0-06B9-47F5-9346-7A829C38B248 + + note + Invoked when you search for a keyword that doesn't match a result on your local. + xpos + 1575 + ypos + 470 + + 249B0782-BFFB-4382-A857-5058D7C3D244 + + note + Define scope based on vaults. + xpos + 840 + ypos + 930 + + 2754DF89-417E-46D0-A435-3ED58F2CB8CF + + xpos + 320 + ypos + 1355 + + 29B3A4DB-80CD-498F-A079-18F1CA7DD20C + + note + Edit subtext to remind yourself of your vault names. + xpos + 115 + ypos + 280 + + 2C31829D-621E-4707-B16D-5899AE7907FD + + xpos + 835 + ypos + 2345 + + 2CC3DBA2-EDA4-4548-A215-611A436E43DB + + note + os. Change settings here. + xpos + 1030 + ypos + 605 + + 2D878E69-78A2-499B-B7F1-BE3B30AD5C70 + + note + Set up: Turn on/off notifications when adding text to inbox note. + xpos + 160 + ypos + 2270 + + 2EEFE48E-B0E2-406A-BCA9-930F5969A364 + + colorindex + 2 + note + Store vault name in variable. Default title can be changed here. + xpos + 835 + ypos + 415 + + 333B2B54-2894-418E-A8DE-522F8BB1F3E5 + + note + Set up: Specify markdown file to use as inbox note. + xpos + 150 + ypos + 2075 + + 353B5FD9-BF6A-4635-9AA1-313E16E86B05 + + note + Obsidian help + xpos + 595 + ypos + 95 + + 360748C4-EF05-4FC2-8AB9-E4A969D2D256 + + xpos + 1655 + ypos + 130 + + 39F0A80F-98F0-47BE-B519-26563D139E54 + + note + replace newline + xpos + 920 + ypos + 1895 + + 3B2DA9A3-761D-467C-BDD7-841584877816 + + note + Set up: Specify hotkey to open inbox note. + xpos + 595 + ypos + 2225 + + 3BD1A5BF-C96B-4C33-B2A6-2EEB18C41B62 + + colorindex + 6 + note + Store file name/title in variable. + xpos + 1095 + ypos + 415 + + 3CF13837-2DBB-46AA-93B4-6CA9598A106E + + note + Open note in Obsidian. + xpos + 1180 + ypos + 385 + + 3DF54CDE-9D13-4486-B7EC-7921A46C8AE2 + + note + Define hotkey to search in vaults. + xpos + 635 + ypos + 1350 + + 3E2AE83C-BAFA-4EB9-ADCB-0BB7989CF9E9 + + xpos + 1185 + ypos + 105 + + 3F7FA866-52E3-46A9-84EE-80A4D3244647 + + note + Set up: Add a vault. + xpos + 145 + ypos + 585 + + 403F9FD9-33F0-42FC-8E20-FEC2C821B083 + + note + Search for recent files (default: last 3 days) + xpos + 645 + ypos + 860 + + 44D69DBA-085D-4208-86A1-CED1CA068AB3 + + note + Search for all files. + xpos + 640 + ypos + 570 + + 46732892-62E0-47CE-B727-EBA967105197 + + note + Define scope based on vaults. + xpos + 840 + ypos + 605 + + 54B8D923-3C08-4CD2-8F05-0AF628F5C029 + + xpos + 110 + ypos + 440 + + 5ADBB309-EC74-453A-B7F5-9E34E2CDB7E3 + + note + or. Change settings here. + xpos + 1025 + ypos + 930 + + 5DE0CED7-F7E2-4A3F-B3A2-53FF23C8C6D3 + + note + Set up: Specify daily note format. + xpos + 155 + ypos + 890 + + 6290B8D5-ECEB-4623-848B-E5AB92089E79 + + xpos + 360 + ypos + 2265 + + 65DEE317-811D-4787-87B4-3909B62061EA + + note + Set up: Specify header of daily note to append todos to. + xpos + 155 + ypos + 1870 + + 67E25071-1FF8-4F8B-9A9F-2509093593B6 + + note + Clear vault. + xpos + 325 + ypos + 1520 + + 6C92B3BB-C347-4EEE-AC10-2EC7E3381F2A + + note + Append text to an inbox note. + xpos + 610 + ypos + 1805 + + 6F34BFA1-14F5-49E9-B25D-417D71A29AD4 + + colorindex + 2 + note + Store vault name in variable. + xpos + 1995 + ypos + 495 + + 6FF78F6F-9167-45D0-B022-7BE55106848C + + note + Define scope based on vaults. + xpos + 815 + ypos + 1230 + + 70AEEB77-35DB-44B9-B633-BE1D2B43D581 + + note + Open note in Obsidian. + xpos + 1275 + ypos + 925 + + 72CFFBA4-02FC-4875-BB2C-562FCF5E43BC + + xpos + 325 + ypos + 1200 + + 73853368-ED10-4729-A4D0-E231647C3CF4 + + xpos + 350 + ypos + 2060 + + 76C3031F-7B85-45C6-9D05-DF5802BBC167 + + note + Daily note. + xpos + 985 + ypos + 170 + + 82B5116A-964C-4E76-AA72-45B844D83BEA + + note + replace newline + xpos + 810 + ypos + 1895 + + 834BB1A9-B643-4448-97B4-B6B6582602CB + + note + Set up: Clear all but help vault. + xpos + 150 + ypos + 1355 + + 854EB1EE-9017-4F43-BC80-BAF317FC5315 + + note + Vault to create new note in. + xpos + 635 + ypos + 380 + + 86967BF2-99A7-43FB-A22A-7AC2F9A8C34C + + colorindex + 6 + note + Store search query in variable. + xpos + 1750 + ypos + 500 + + 8B221971-0089-4DAC-A056-EC2C961C6EAB + + note + Title of new note. + xpos + 925 + ypos + 385 + + 8C017EEF-38DD-4148-9291-9302EFCE33DE + + note + Set up: Specify daily note directory/path. + xpos + 155 + ypos + 1200 + + 9295060C-B513-4806-8F12-52EC6D30C9A3 + + note + Define hotkey to search in vaults. + xpos + 640 + ypos + 700 + + 9F656256-DD01-4508-BF9F-CDB3168DB9B6 + + xpos + 765 + ypos + 180 + + A60FCD19-F3A3-4B26-BDB2-52D548E38686 + + xpos + 120 + ypos + 140 + + A70B656D-CA4C-41F9-99E3-988FB6158F5F + + xpos + 325 + ypos + 585 + + A7CCBBCE-F078-4780-BF5C-42D9CE64D568 + + note + Set up: Specify hotkey to append clipboard contents inbox note. + xpos + 610 + ypos + 1975 + + ADAB8847-A309-4A02-9D42-E8D30C47BC5D + + note + Set up: Specify daily note vault. + xpos + 150 + ypos + 735 + + B1E46976-D5FD-41F9-AC39-C5F7D93F53E7 + + xpos + 350 + ypos + 1865 + + B768A804-C61E-4133-AB9C-74C6448BFC62 + + note + Open/create today's daily note. + xpos + 975 + ypos + 10 + + BDE4BB5C-ECD8-439A-B893-A9C70345010D + + xpos + 120 + ypos + 15 + + C016E20E-3F44-4372-90DC-1B00DA8C07F8 + + note + ot. Change settings here. + xpos + 1020 + ypos + 1230 + + CD6980A3-E50D-4689-B8D6-1A677CDE1914 + + xpos + 1840 + ypos + 470 + + CDEBE435-E442-4054-80BE-59ADD7EEA597 + + note + Append text to end of note as list item. + xpos + 1045 + ypos + 1865 + + CEC4065E-BADA-44B7-A255-4A9D613685E2 + + note + Define hotkey to search in vaults. + xpos + 645 + ypos + 1010 + + D79944EC-E799-4CC4-9961-A6EBF5D6FBDC + + xpos + 325 + ypos + 890 + + DE762236-EFCC-45D3-85CA-A1B6B191762C + + note + Open search pane in Obsidian vault. + xpos + 2075 + ypos + 465 + + E5FAA23D-08AB-47A3-A5C9-5211B9D677C4 + + xpos + 355 + ypos + 1705 + + E6955BE2-FEB7-470D-92BE-03EDF6C498FB + + xpos + 325 + ypos + 735 + + F118473C-D1EF-472F-A1F6-CC9A8C65ABF2 + + note + Open/create tomorrow's daily note. + xpos + 1455 + ypos + 145 + + F565051F-71D8-42F7-A733-5DA9F39AAEA2 + + note + Set up: Specify daily note template. + xpos + 155 + ypos + 1050 + + F8C5232B-3EDC-4388-851E-BFE6602C88D0 + + xpos + 325 + ypos + 1050 + + FFD4328D-FE08-4222-8AA1-FD71A1DC33F9 + + note + Search for files modified today + xpos + 640 + ypos + 1185 + + + variables + + dailyabspath + + dailyformat + + dailyheader + + dailytempabspath + + dailytodaypath + + dailytodo + + dailyvault + + dailyvaultname + + inbox_md + + oinotify + on + vault1 + obsidian help + vault1name + obsidian help + vault2 + + vault2name + + vault3 + + vault3name + + + variablesdontexport + + vault3name + inbox_md + vault3 + dailyvaultname + vault2 + dailyabspath + dailytodo + vault2name + dailyformat + dailytodaypath + dailytempabspath + dailyvault + dailyheader + + version + 0.3.1 + webaddress + https://github.com/hauselin/obsidian-alfred + + diff --git a/tests/oi.js b/tests/oi.js deleted file mode 100644 index f427f4d..0000000 --- a/tests/oi.js +++ /dev/null @@ -1,90 +0,0 @@ -ObjC.import('stdlib'); -console.log('Running script: oi') - -// get the current app to access the standard additions -app = Application.currentApplication(); -app.includeStandardAdditions = true; - -// get home path -homepath = app.pathTo('home folder') -console.log(homepath) - -// get inbox note path -var inbox_md = $.getenv('inbox_md'); -inbox_md = inbox_md.replace('~', homepath) - -// escape " -var query = "{query}"; -query = query.replaceAll('"', '\"'); - -// 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' }) -} diff --git a/tests/scratch.js b/tests/scratch.js deleted file mode 100644 index 2eea88f..0000000 --- a/tests/scratch.js +++ /dev/null @@ -1,47 +0,0 @@ -try { - // var filetext = app.read(path) - var filetext = readFile(inbox_md) - // console.log(filetext) - - if (!filetext.endsWith("\n") && !filetext.endsWith("- ") && !filetext.endsWith("-")) { - console.log("does not end with newline character") - text2append = "\n" + text2append - app.write(text2append, { to: openedFile, startingAt: app.getEof(openedFile) + 1 }) - } else if (filetext.endsWith("\n")) { - console.log("ends with newline character") - console.log('remove newlines') - while (filetext.endsWith("\n")) { - filetext = filetext.slice(0, filetext.length - 1) // remove newline characters - } - filetext += ("\n" + text2append) - console.log(filetext) - app.write(filetext, { to: openedFile, startingAt: 0 }) - } else if (filetext.endsWith("- ")) { - console.log("ends with hyphen") - text2append = text2append.slice(2) - console.log(text2append) - app.write(text2append, { to: openedFile, startingAt: app.getEof(openedFile) + 1 }) - } else if (filetext.endsWith("-")) { - console.log("ends with hyphen") - text2append = text2append.slice(1) - console.log(text2append) - app.write(text2append, { to: openedFile, startingAt: app.getEof(openedFile) + 1 }) - } - app.closeAccess(openedFile) - done = 1 -} -catch (error) { // empty file without any characters - app.write(text2append, { to: openedFile }) - app.closeAccess(openedFile) - done = 1 -} - - - - - - - - - -