![]() ![]() One oddity: I did try to store a JavaScript Date in the result objects, to use in the final sorting, but LaunchBar displays an error if a Date in the returned items. And in lines 9–12 we use the formatDate function on the LaunchBar object, which gives us access to the system’s date formatting, which is both locale-aware and respects the user’s date & time preferences.īy providing the path in the result object, LaunchBar treats each entry in the list as a file, so you can press return to open it, or press the right arrow to inspect its details. In line 3, we make use of the File object, which is provided by LaunchBar. ![]() sorting those objects on the ISO date string, newest to oldest (lines 25–29).creating an object containing a human-readable date, the path to the file, and an ISO-format date string (lines 7–24).keeping only those whose filenames match dated shortlog files (lines 5 & 6).reading the contents of a directory (lines 3 & 4).We treat this as a simple pipeline of transformations on data: This is just a “default script”, and while run takes an argument, it’s ignored. You can read about the properties items can have in the LaunchBar action developer documentation.ġ function run ( argument ) One thing to note is that it returns a result of type “Item” - an array of JavaScript objects with particular keys. This is a default script, taking no input. Here are the settings in the scripts pane in LaunchBar’s Action Editor: (And, to be clear, this isn’t JXA either.) LaunchBar provides some additional tools to make interacting with the system straightforward from JavaScript. I wrote it in JavaScript as the documentation leads you that way, and you don’t have to serialise to JSON and write to stdout to return values. So I thought I would write a LaunchBar action to do both.ĭespite being my first, it was really very easy. However, that doesn’t resolve the problem that it’s not always easy to realise that is “Monday”. You can reverse this by holding down command when navigating into the folder in LaunchBar. By default these are listed in lexicographically ascending order. I have my shortlog folder indexed by LaunchBar, so I can browse the files that way. Listing shortlog files chronologically with LaunchBarīuilding on my introductory post about maintaining “shortlog” diary files, I quite often want to have a look at recent shortlog files. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |