I’m still amazed how long I can do something before realizing “Oh right, I should automate this.” You’d think I’d have learned by now.
Today’s example: I’m constantly opening a BBEdit file in Marked. Now, I do have a BBEdit script to do this so I can go to the Script menu in BBEdit and then select “Open in Marked” but I hate using the trackpad, so why didn’t I make a keyboard shortcut for this ages ago?
Then, when I went to do that, I realized: “Wait. When I open a BBEdit file in Marked, the next thing I do is put the BBEdit window on the left, and the Marked window on the right. And if the dock (which I keep on the left) is visible, I want to hide that, so I can maximize screen space on my MacBook Air.”
So instead of just making a keyboard shortcut to do one thing, I made a macro that does all of the things:
Runs a shell command
defaults read com.apple.dock autohideto see if the dock is hidden or not. If hidden, run keyboard shortcut ⌘⇧D to hide the dock.
Resize front BBEdit window to left “column” / left side of the screen.
Select the Script menu in BBEdit and run my
Open in Marked.shscript (this uses a BBEdit variable for the front-most document, so it’s easier to do it this way than via Keyboard Maestro.)
The script opens Marked (technically Marked 2)
Keyboard Maestro waits until Marked has launched, is front-most, and has a window with a title, then moves it to the right “column” / right side of the screen.
Activates BBEdit again so keyboard focus will be back in my BBEdit document.
Again, not hard, not very complicated, but I will use this all the time.
Installing the BBEdit Script
To install the BBEdit script, select the “Scripts” item from the BBEdit menu and choose “Open Scripts Folder” as shown here:
You can download my ‘Open in Marked’ BBEdit script from GitHub.
It’s pretty straight-forward. What you want to do is this:
open -a ‘Marked 2' "$BB_DOC_PATH"
If you use Setapp, you need to change it slightly to this:
open -a 'Marked' "$BB_DOC_PATH"
My script will check for the app and both places, and use whichever one exists. If neither exists, it will throw an error.
Here's the macro
I think it's pretty self-explanatory, but feel free to ask questions if you have any.
Download the Macro
BBEdit - Open in Marked.kmmacros (58 KB)