--- tags: Random title: Setting up some Mac keyboard shortcuts I like on new computer --- # Setting up some Mac keyboard shortcuts I like on new computer [toc] > **NOTE** > Some things have changed in new macOSs. See very bottom for updated way of creating keyboard shortcuts (at least for the word/character count one, likely different still for these workflow types - they were in "General" in the Service menu after i created them). Though new ones dont' seem to be :( ## iTerm launch (or open new window if already open) - in automator (that's the program) - document type to create is "Quick Action" - set up top options like this: ![](https://i.imgur.com/lOBe1Ry.png) - drag Run AppleScript into panel ![](https://i.imgur.com/M5K4xQ0.png) - put this text in there: ```script if application "iTerm" is not running then activate application "iTerm" else tell application "iTerm" create window with default profile activate end tell end if ``` - save it ![](https://i.imgur.com/oriWKcF.png) ![](https://i.imgur.com/oO29Sfp.png) - create shortcut - system preferences - keyboard - shortcuts - services - scroll down to what we made, and click add shortcut ![](https://i.imgur.com/anPxloW.png) ## Launch Chrome (or new window if already open) - same as above, except this is the code in the Run AppleScript window ```script if application "Google Chrome" is not running then activate application "Google Chrome" else tell application "Google Chrome" make new window activate end tell end if ``` ## Launch BBEdit (or new window if already open) - same as above, except this is the code in the Run AppleScript window ```script if application "BBEdit" is not running then activate application "BBEdit" else tell application "BBEdit" make new text window activate end tell end if ``` ## Launch VSCode (or open new window if already open) - in automator (that's the program) - document type to create is "Quick Action" - set up top options like this: ![](https://i.imgur.com/mRrkWAX.png) - drag Run AppleScript into panel from left: ![](https://i.imgur.com/t1poPKk.png) ![](https://i.imgur.com/jeuEMlS.png) - put this text in there: ```script if application "Visual Studio Code" is not running then activate application "Visual Studio Code" else tell application "Visual Studio Code" # can't figure out what's needed here activate end tell end if ``` As noted, i can't find the write wording to launch a new one if it's already ready open. So this connects to it and then can do `CMD + SHIFT + N` for a new one... - save it ![](https://i.imgur.com/f5wQ8an.png) - create shortcut - system settings - keyboard - keyboard shortcuts - services - old ones are in general, but new ones are not after latest OS update :( - not sure what to do about this yet ## Launch Stickies app – my labels for each different desktop :) - same as above, except with this code in the Run AppleScript window ```script activate application "Stickies" ``` ## Word count on any highlighted text --- > **NOTE** > The below stopped working for me on newer macOSs. Found this [macrumors page](https://www.macrumors.com/how-to/system-wide-word-count-service-macos/) with a slightly different process that did work, so i'd start with that :+1: > > > Except, it was giving 1 more than expected for character counts for reasons i couldn't figure out. I put in this to correct for that: > ```bash > echo Words: > echo $1 | wc -w > echo "" > echo Characters with spaces: > echo "$(($(echo $1 | wc -c) -1))" > ``` > Then create a keyboard shortcut as described below --- - in automator (that's the program) - document type to create is "Quick Action" - set up top options like this: ![](https://i.imgur.com/o8GnfHq.png) - drag Run Shell Script into panel from left ![](https://i.imgur.com/tRqjiFL.png) - put this text in there: ```script echo Words: echo $1 | wc -w | tr -d " " echo "" echo Characters with spaces: echo $1 | wc -c | tr -d " " ``` - save it ![](https://i.imgur.com/oriWKcF.png) ![](https://i.imgur.com/9zmCQRE.png) - create shortcut - system settings - keyboard - keyboard shortcuts - services - click 'Text' dropdown - find what you saved it as, double click the right side to be able to enter the keyboard shortcut to trigger it