Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save offlinemark/54d0f42f2c00f8b3e8ebb9fd7c50785f to your computer and use it in GitHub Desktop.
Save offlinemark/54d0f42f2c00f8b3e8ebb9fd7c50785f to your computer and use it in GitHub Desktop.
apple script for focusing on an omnifocus folder, with chooser
on run
-- Preselected folder names (replace with your own folder names)
set preselectedFolders to {"Life", "Work", "Media"}
-- Display a chooser dialog to select a folder
set chosenFolder to choose from list preselectedFolders with prompt "Choose a folder to focus on:" default items {"Life"}
if chosenFolder is false then return -- user canceled
-- Get the selected folder name from the list
set chosenFolder to item 1 of chosenFolder
-- Tell OmniFocus to find and focus on the selected folder
tell application "OmniFocus" to tell the default document
-- Find the folder(s) whose name exactly matches the chosen folder name
set folderList to folders whose name contains chosenFolder
if folderList is not {} then
tell the front document window to set focus to item 1 of folderList
else
-- Alert if no matching folder is found
display alert "Folder \"" & chosenFolder & "\" not found."
end if
end tell
-- Unfold (expand) the complete folder hierarchy in the sidebar
tell application "System Events"
tell process "OmniFocus"
set frontmost to true
-- Option 1: Try clicking the "Expand All" menu item from the "View" menu
click menu item "Expand All" of menu "View" of menu bar 1
end tell
end tell
end run
@offlinemark
Copy link
Author

to install keyboard shortcut for this:

  • open automator.app
  • add new
  • add new applescript to workflow
  • copy paste this in
  • save
  • add shortcut: System Preferences > Keyboard Shortcuts > Services > General
  • Suppress security warning: System Preferences > Security > Accessibility , click plus button, add omnifocus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment