A Few Favorites: Open Apps, Files, Folders
*Updated: 5 October
This macro opens apps, files and folders (including mounted drives) using either an HTML form or a Popup menu. Apps are launched or, if already open, switched to the front. Files are opened by the default application. Folders can be opened in the Finder or an Open/Save dialog.
Moderator Edit: For those of you who would like to download the excellent documentation provided in this post, I have created and uploaded the following PDF. It did require some edits due to the way the forum SW prints to a PDF. Any errors or omissions are mine.
A Few Favorites Macro Documentation - KM Forum.pdf.zip (566.7 KB)
HTML interface:
2021*
Popup interface:
BACKGROUND
This macro was inspired by two other macros:
-
Ccstone: Open a Folder in the Finder via a Path List in a User Prompt - #3 by ccstone
-
BKramer: Quickly Navigate to Favorite Finder Directories Via Dictionary-Generated List Prompt
While there are a lot of way to cursor and click your way around the system, I was intrigued by the idea of having a list of a few of my favorite things available at the touch of a keystroke. Not just folders, but files especially and even apps.
I wanted to open the folders in the finder but also to go to them in Open/Save dialogs.
And I thought I'd like to try an HTML interface to keep all three types of things visually separate. But I also liked the efficiency of the Popup interface, so I thought I'd include both.
Finally, I liked the idea of a macro to edit the file of favorites but I wanted it incorporated into the main macro.
This evolved with use. In fact, this is the third version. I started with one favorites file in one HTML list which became three lists, making it easy to add and edit items. It went as far as including recent apps, files and folders but that ran too slowly and didn't allow controlling the width of the select fields in the HTML form.
To make the three lists in the HTML form more easily apparent, I added icons to the edit buttons. And I restricted the tab navigation to just the lists so you can easily call the macro, pick a list and an item then hit Return to do what you want without mousing around at all.
For the Popup, I settled on tags to identify apps, files and folders separately to provide a similar display to the HTML form. I also set up a button convention (square brackets) for editing the favorites files and getting help.
It has taken a while to get in the habit of using this macro but I've come to really like the keyboard-centric navigation whichever interface you use.
While not a full-fledge launcher application, this macro simplifies the less elegant cursor-and-click approach, which nevertheless remains available. But its real value is that the things I regularly use and want to open are just a couple of keystrokes away now.
DEFAULT HOT KEYS
-
F4 to call the HTML interface
-
Shift-F4 to call the Popup interface
-
Option-F4 to add the Finder selection to a favorites file
FAVORITES FILES
The three favorites files (apps.txt, files.txt and folders.txt) use the same data format):
Heading
[tab]Descriptive Name[tab]Path[tab]@shortcut, @shortcut
Tilde is supported in the path (eg: ~/Documents rather than /Users/username/Documents).
Lines beginning with # are treated as comments.
Headings, which are only used by the HTML interface, are optional and ignored by the Popup list.
The Descriptive Name can include a tag as a shortcut or even a filter indicating whether the path is to a folder or a file. The macro figures it out itself for the HTML form but the Popup can use a filter for navigating the lengthy list.
These shortcuts are optional and disregarded by the HTML form.
OPERATION
On first run, you'll be prompted for the location of your favorite app, folders and files files. There are three: apps.txt, files.txt and folders.txt to facilitate adding Finder selections to the right list.
Sample files are provided in the distribution, along with an images folder with the HTML interface's icons.
The HTML interface (F4) displays a separate list for apps, files and folders with a label that is also a button to edit that list. The active list is indicated by a highlighted border in the HTML form. You can tab between lists. By default, you are addressed to Files. Tab to address Folders. Shift-Tab to address Apps. A Help button displays most of this information.
You can navigate the HTML form by typing the name of the item you want or repeatedly typing the first letter. When you have arrived at the item you want, just type Return or click the OK button on the HTML form.
The Popup simulates the HTML buttons with a "[Text]" convention. It has three options that begin with "[Edit" at the bottom to edit any of the three source files, as well as a "[Help]" option.
You can navigate the Popup by typing the item's name or its tag to narrow the list. Press Return or double click on the item.
If you select an app, the macro will launch the app or, if it's already running, switch to it.
It will open any favorite file in its default application.
If you select a folder with an Open/Save dialog is at the front, the macro will redirect the dialog to the appropriate folder, otherwise it will open the selected folder in the Finder.
You can add a selected app, file or folder in the Finder, by using the Option-F4 hot key. The macro will ask how you want to add it to the appropriate source file. If you add it, you'll be asked if you want to edit the file so you can move the new listing.
Listings are not sorted by the macro. You can order them however you like and that's how they'll appear.
INSTALLATION
The macros is installed in the Global Macro Group as A Few Favorites, available to all applications all the time.
The default hot key is F4, which intentionally conflicts with the distribution Open Home Folder in the Global Macro Group. It effectively replaces that macro if you include your home folder in the folders.txt file.
By default, the hot key by itself calls the HTML form. With the Shift key, it calls the Popup. You can switch that around as explained below if you prefer to call the Popup more often than the HTML form.
The function to add a Finder selection relies only on the Option key.
While Stone creates a base favorites file if none exists, Open Favorites does not. Instead it ships with sample files you can copy to a convenient location. It does ask for the folder you've put them in on first run.
You can populate those files by selecting apps, folders and files but you'll want to manually edit them into helpful categories if you use the HTML form.
There is only one global variable used (favsHome). It remembers where your favorites.txt file is and is used by both macros in the set. All the other variables are locals that are not saved.
Icons are from the IcoMoon-Free set from Keyamoon (http://keyamoon.com). They are installed with the favorites files in a sub-folder names "images."
CUSTOMIZATION
You can change the hot key, of course. I choose a function key to make it easy to access without remembering a key chord. F4 brings up the HTML form and Shift-F4 brings up the Popup.
And you can swap which interface requires the Shift key by making the Shift the pressed modifier and deselecting it in the not pressed row of the appropriate If action.
If you use rather long stubs to describe your paths, the width of the HTML "select" field will grow and push the others to a new row, obscuring them. Keep your slugs to no more than 18 characters to avoid this. Alternately, you can widen the window.
You can pick which of the three HTML "select" lists gets focus by moving the "autofocus" option to the "select" you prefer. The default sets Files to autofocus so Shift-Tab moves to Apps and Tab moves to Folders.
I've established a different tag for apps, files and folders so I can filter the list in the Popup interface: @a is for apps, @f for files and @d for folders (directories). And buttons all begin with "[". That can provide a similar function to the three "select" lists in the HTML form.
I've set variables to check for the Shift and Option keys to avoid any processing delay caused by the initial code that would miss the key press.
I've also put the Help text (based on this document) in a variable because it appears twice in the macro. This way the text is stored only once and, as a local variable, not remembered outside the macro.
The macro distinguishes file types by the extension. It knows .app is used for .apps and any other three or four character extension is a file. Anything else it assumes is a folder. This has worked reliably in my testing.
The Option key replaced an earlier version which just looked for a Finder selection. I found that I often had a Finder selection somewhere, which I had no intention of adding to a favorites list. So I reverted a more conscious implementation over automatic. You always know when you want to add a selection to a file.
You can also add multiple selections to a variety of files, too. You'll be prompted for each one.
And you can add external and internal drives to the folders list as well.
Adobe Open/Save dialogs are unmoved by this macro. Otherwise it has worked well with the applications we've used.
A Few Favorites.34a.zip (25.6 KB)
RELEASE NOTES
3.4a on 5 October 2021
-
Changed just one character from a space to an underscore of the global macro name that remembers what you last ran so it does indeed remember what you last ran. The previous version seemed to remember with the space in the name, but it should properly be an underscore. So now it is.
-
I've also added a title tab and version number in the HTML interface, a convention I've adopted for more recent MacroApps.
3.3a on 13 February 2021
- Support for double clicking options in the HTML form added.
3.2a on 29 December 2020
-
Added popup File menu to Add an Entry (Option-F4) which defaults to best guess so you can set the correct file for odd file extensions. Revised the local variable names to clean up the form a bit, too.
-
Included prompt to edit favorite file in Add Entry loop. If you click Yes, the file will open but the macro will continue to process any other Finder selections. So if you have a mix of apps, files and folders selected, you can add them and open the files as you work through the list.
3.1f on 29 December 2020 [not released]
- Changed Add Finder Selection List option to recognize BBEdit project filenames and text clippings as files using .([a-zA-Z]{3,4}|bbprojectd|textClipping)$ as the regexp instead of .[a-zA-Z]{3,4}$ You can add any other atypical extension using the same trick (a vertical bar and the extension inside the closing parenthesis).
3.1e on 17 December 2020
- Initial release