Try โ€‚โ€‰HackMD

Setting up some Mac keyboard shortcuts I like on new computer

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:

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • drag Run AppleScript into panel

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • put this text in there:

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
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

  • create shortcut
    • system preferences
    • keyboard
    • shortcuts
    • services
    • scroll down to what we made, and click add shortcut

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

Launch Chrome (or new window if already open)

  • same as above, except this is the code in the Run AppleScript window
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
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:

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • drag Run AppleScript into panel from left:

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

  • put this text in there:
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

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • 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
activate application "Stickies"

Word count on any highlighted text


NOTE
The below stopped working for me on newer macOSs. Found this macrumors page with a slightly different process that did work, so i'd start with that

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

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:

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:

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • drag Run Shell Script into panel from left

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • put this text in there:

echo Words:
echo $1 | wc -w | tr -d " "
echo ""
echo Characters with spaces:
echo $1 | wc -c | tr -d " "
  • save it
    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More โ†’

  • 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