I screwed up and now can't see all the macros

For that matter someone would reset Keyboard Maestro “accidentally” and be all angry about the fact that they could.

It only takes 1 line in the Terminal to find all the relevant files and folders:

find  ~/Library/Preferences ~/'Library/Application Support' -iname "Keyboard Maestro" -or -iname "*com.stairways.keyboardmaestro*" -depth 1
~/Library/Preferences/com.stairways.keyboardmaestro.editor.plist
~/Library/Preferences/com.stairways.keyboardmaestro.engine.plist
~/Library/Preferences/com.stairways.keyboardmaestro.plist
~/Library/Application Support/Keyboard Maestro

It's easy enough to turn that into a shell script to delete them.

This shell script only reveals them in the Finder (for safety).

# Reveal Keyboard Maestro preference files and App-Support folder in the Finder
kmItemList=$(find  ~/Library/Preferences ~/'Library/Application Support' -iname "Keyboard Maestro" -or -iname "*com.stairways.keyboardmaestro*" -depth 1);
while read -r thePath
do
    open -R "$thePath";
    sleep 1.5;
done <<< "$kmItemList"

For a full-on trash-the-files-and-folders solution see this:

WARNING: Misuse of this script could DESTROY all of your Keyboard Maestro macros.

NOTE: moveFoundItemsToTrash is set by default to false, so the script will only return the paths to the items. Change moveFoundItemsToTrash to true to move Keyboard Maestro's preferences and App-Support folder to the Trash.

Trash Keyboard Maestro Preferences & Application Support Folder.scptd.zip (12.8 KB)

--------------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2016/09/11 20:20
# dMod: 2016/09/11 21:52
# Appl: Keyboard Maestro
# Task: Trash Keyboard Maestro Preferences & Application Support Folder
#     : OR return a text list of their POSIX Paths.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Finder, @Keyboard_Maestro_Engine, @System_Events
#     : @Trash, @Keyboard_Maestro, @Preferences, @Application_Support, @Folder
--------------------------------------------------------------------------------

property moveFoundItemsToTrash : false

--------------------------------------------------------------------------------
# Find Keyboard Maestro's preference files and its Application Support folder.
--------------------------------------------------------------------------------

set shCMD to "find  ~/Library/Preferences ~/'Library/Application Support' -iname \"Keyboard Maestro\" -or -iname \"*com.stairways.keyboardmaestro*\" -depth 1"
set foundItemList to do shell script shCMD

if foundItemList = "" then error "No Keyboard Maestro items were found!"

--------------------------------------------------------------------------------

if moveFoundItemsToTrash = true then
   
   set dialogButtonResult to button returned of (display dialog "Are you SURE you want to move Keyboard Maestro's preferences and Application Support folder to the trash?" with title "WARNING!" with icon 2)
   
   if dialogButtonResult = "OK" then
      
      --------------------------------------------------------------------------
      # Quit Keyboard Maestro Editor and/or Keyboard Maestro Engine if running.
      --------------------------------------------------------------------------
      
      tell application "System Events"
         set foundProcessList to name of processes whose name contains "Keyboard Maestro"
      end tell
      
      if length of foundProcessList > 0 then
         
         repeat with theProcess in foundProcessList
            tell application theProcess
               quit
            end tell
         end repeat
         
         delay 3
         
      end if
      
      --------------------------------------------------------------------------
      # Convert POSIX Paths into an alias list for better handling.
      --------------------------------------------------------------------------
      
      set foundItemList to paragraphs of foundItemList
      
      repeat with thePath in foundItemList
         set contents of thePath to alias POSIX file thePath
      end repeat
      
      --------------------------------------------------------------------------
      # Move found items to the Trash.
      --------------------------------------------------------------------------
      
      tell application "Finder"
         activate
         open trash
         delete foundItemList
      end tell
      
      --------------------------------------------------------------------------
      
   end if
   
else if moveFoundItemsToTrash = false then
   
   -----------------------------------------------------------------------------
   # Return POSIX Paths as text.
   -----------------------------------------------------------------------------
   
   return foundItemList
   
   -----------------------------------------------------------------------------
   
end if

--------------------------------------------------------------------------------

-Chris

2 Likes