(Note: While this is directed mainly for Safari users, I have included instructions at every step for doing this for other apps as well!)
A pain every Safari user shares is trying to hit ⌘W, and instead ending up hitting ⌘Q. This closes all the tabs that are currently open in Safari, and you lose all your progress. To re-open all windows, you have to go into the menu bar -> History -> Restore all windows from the last session.
You can mitigate this issue by going to Safari Settings and enabling the option shown in the image, under the General section.
But this only mitigates the hassle, it still makes you lose your important work if you accidentally quit.
Other competing browsers warn the user before quitting, Safari doesn’t. But what if we could add that functionality to Safari?
Well, I tried looking online, and I found this article from John Gruber, but it requires the user to have an app called FastScripts, that lets you run AppleScripts by listening to your keyboard shortcuts before Safari does, but it costs $40 for a single user license. Now that is quite the price to pay for a single Safari feature that should have been free in the first place, but I think we can do better for free! (Sorry, FastScripts!)
Given the Siri Shortcuts aficionado that I am, I knew there would be a way to do this with Shortcuts, and there is— it’s just not as straightforward as you think it might be. I’m going to take this a step further by extending it beyond just Safari. Let’s tackle this step-by-step.
Step 1: Disable the ⌘Q Shortcut.
Head to your Mac’s System Preferences (or now, System Settings). And open the Keyboards Panel. Then, click Keyboard Shortcuts…
Then, go to the App Shortcuts section. Click + and add a Shortcut for Safari.
Type in the menu title as “Quit Safari”, letter for letter. If you make a spelling error, this will not work.
Then, type in the Keyboard Shortcut as ⌘⌥Q. (See image for configuration!)
Rinse and repeat for all the apps you want to do this for! Keep in mind that selecting “All Applications” will not work, since it requires you to type in the exact name of the app in the Menu Title field. You can’t automate this process, unfortunately!
For many of you, this might be enough to avoid the Command Q issue altogether, but we can improve the experience even further while still making use of the Command Q function.
Step 2: Add a Confirmation Pop Up.
Let’s take the AppleScript from Daring Fireball’s post, and turn it into a Siri Shortcut. I’ve done this step for you, so the only thing you need to do is set it up. As I mentioned earlier, this script has been modified even further to add compatibility for apps outside Safari, but you can expect additional functionality when quitting Safari.
First, please make sure you go to Shortcuts Settings -> Advanced and enable Allow Running Scripts. This is required for this shortcut to work, since it relies on AppleScripts.
Install the App Quit Confirmation Shortcut by clicking the button:
Follow the on-screen instructions for set-up.
Once you’ve installed the shortcut, open the Shortcuts Editor for the Siri Shortcut.
Go to the Info Tab on the top right. And click Add Keyboard Shortcut. Type in ⌘Q.
But wait, that quits the Shortcuts app altogether. But worry not, we have a solution for exactly that.
Open System Settings again, and repeat the process we did earlier, but now for Shortcuts. (See image below)
Click Done before moving on. This will (temporarily) disable the Command Q shortcut from quitting Shortcuts, so you can safely enter the keyboard shortcut into the configuration.
Now, go back to Shortcuts, and set up your keyboard shortcut as ⌘Q. This time, the app will no longer quit, and will instead register the keyboard shortcut.
Make sure you go back to Settings, and remove the keyboard shortcut modification you just added to Shortcuts, unless you’d like to add a confirmation to Shortcuts too!
And that’s all. Enjoy the Quit Confirmation, and a better Mac experience overall! (yes, I’m a mad-lad with 300+ tabs open)
Thanks for tuning in, I hope this helped you out!
コメント