5 ms·
Taking command of the Context Menu in macOS
- rkwz 2y ago> Submenu is optional > Apply to multiple types (files or directories; can be as granular as file extension) > Show output (sometimes you want to see the results of the command) > Confirmation before running (if it’s a potentially dangerous operation) Nit: The last 2 points are actually possible in Automator Some examples: * Remove PDF password: https://www.sheshbabu.com/posts/remove-pdf-passwords-using-qpdf-and-applescript/ https://www.sheshbabu.com/posts/remove-pdf-passwords-using-q... * Summarize text with Ollama: https://www.sheshbabu.com/posts/system-wide-text-summarization-using-ollama-and-applescript/ https://www.sheshbabu.com/posts/system-wide-text-summarizati...
- msephton 2y agoFair point! My memory is hazy :)
- kelsey98765431 2y agoI enjoy some cool macos tricks, but the bash substitution was something I had never seen! Very neat, I looked into it briefly and it looks like using {@%.*} is not posix compliant, but a bashism. However the substitution itself is posix compliant, so I may start using something like this in my scripts. Need to look at this more, but this is a heck of a lot less clunky than `echo | sed`... I need to go read `info coreutils` more closely.....
- msephton 2y ago${@%.*} is valid in both bash (old macOS default shell) and zsh (current macOS default shell).
- jbverschoor 2y agoDon’t invest in abandoned applications and frameworks
- nerdjon 2y agoI assume you might be talking about the Mac app that has not had an update since 2023. But why do we consider that abandoned? It seems like the kind of thing that if it works, why keep updating it? Now if it broke in a new version of Mac and it wasnt updated, sure we could call it that. But from what I can tell this is not the case.
- chrisandchris 2y agoHe must be a web developer. If it isn't updated on Sundays or reinvented every uneven month, it must be unusable. /s
- slmjkdbtl 2y agoDo they mean to use Shortcuts instead of Automator? It does seem Apple moved their focus to Shortcuts, which does cover the features Automator has (at least for my use cases, curious to hear the differences and the state of these 2 apps from people more informed)
- nerdjon 2y agoYou know, I always forget the shortcuts has come to Mac. I use it quite a bit on my iPhone but have yet to really explore it on my Mac. But that is a really good point, I am curious why both continue to exist except for not wanting to break existing Automator... automations? I am not sure what they are called. Autommator does still have the major functionality (when it works) of being able to record your actions and just do those. Which shortcuts cannot do. Apparently you can just convert automator to shortcuts: https://support.apple.com/guide/automator/use-your-workflows-with-shortcuts-autc12e3fb97/mac https://support.apple.com/guide/automator/use-your-workflows... I would bet that it is the "record" functionality keeping it around (beyond just the "multi-year transition" apple said they were doing in 2021), but maybe there are some other power features that are unavailable in shortcuts yet.
- msephton 2y agoWhich application or frameworks are you referring to? I've been running this setup for well over a decade.
- a1o 2y agoIt’s weird how hacky macOS feels compared to Linux, where you can get a good idea on how things works due to openness and Windows, due to the good documentation Microsoft offers. In macOS it always feels like you have to be grateful about whatever is allowed and depend on mysterious closed source software.
- frou_dh 2y agoIf you've been a techy Mac user and don't know about Automator then it's a you problem. It was evangelised quite heavily and has been in its final form for a long time. These are its twilight years as the new-ish Shortcuts system takes over.
- mediumsmart 2y agoexactly. https://macosxautomation.com https://macosxautomation.com thank you Sal Soghoian
- msephton 2y agoI think it's worth celebrating users discovering new things. We were all that user at one time.
- frou_dh 2y agoOn second thoughts, I think the person I replied to was perhaps talking specifically about the (in)ability to put things at the root of the menu. So I apologise if that was the case.
- nerdjon 2y agoI am curious what about this you consider hacky? Everything except for the last part of this is native functionality built into Mac. Automator is an app every Mac ships with and it natively has the ability to put things in your Quick Actions, make folder actions, etc. The only real hacky part of this is that it is stuck within the "Quick Actions" menu instead of just being part of the dropdown and this app addresses that. But thats a fairly small part of this implementation.
- serjester 2y agoI use this to easily convert files and some basic data munging scripts - I’d be super curious what other people are doing.
- msephton 2y agoAt the bottom of the blog post I link my repo with actions covering dozens of use cases.
- nerdjon 2y agoI have recently been looking at how I can use some Mac native tools to improve my workflow. Finally exploring tags and smart folders for example. I even built my own Mac app which sits in my menubar syncing tags on project folders with the status of projects in a web app I built. Even better that is synced with iCloud so I can access all of those files and tags from my other devices. I had not considered how else I could improve this situation with context menu options, but now I want to explore how I could use Automator to improve this setup even more.
- msephton 2y agoGood work! Keep going with it. Power user status.
- nerdjon 2y agoIts kinda funny, I have shown 2 people this tool so far. One is another engineer, who we kinda laughed over a tendency to spend an insane amount of time automating things that are quick. Like adding a tag to a folder is quick, I just didnt want to do it and things get out of sync. But he also thought it was really cool and also did not really know about tags until we started talking about this. Kinda like me, he knew they were there but just never did anything with it. I also showed it to my partner who kinda just keeps laughing every time he sees me glued to my laptop debugging this thing and tweaking it. It has honestly been a really fun project though. Trying to keep things as native functionality as possible since the entire point of this is to make it so I can more easily work on a script or some other supporting document for a project on my iPad or iPhone and once I get on my Mac everything will just fall into place. I even made it so if I make a folder, it will send the name of that folder to my web app as a new project. (well the web app handles if its new or not, but still). My only real annoyances so far: 1: Mac doesn't have the ability natively to automatically tag all files in a folder that the tags of the parent folder. I could script this, and I might. But I kinda wish I didn't have too. 2: Why is there no ability in Swift or a Mac app in general to read the contents of a Pages file. Honestly this kinda drives me insane. (I found a workaround by using a github project to turn it into HTML, but that really should not be necessary). 3: I really wish I could make a smart folder that would show me files based on the tags of the parent folder. This way I could have 2 folders in different locations (one that syncs with iCloud and one that syncs with my NAS with very different data, but used in combination) and I could create a smart folder with a single view of all of those files. But this unfortunately seems impossible. (Edit: I guess I could just automatically create symlinks, but a smart folder would be so much cleaner)
- MaxikCZ 2y agoIs there a way to remove certain things from macos context menu? Ideally to just hide them unless I hold Shift or some other modifier?
- msephton 2y agoWhat certain things? Using ContextMenu.app (yes) Automator (no) standard macOS (no) The key point is it only shows things in the right context: every item can be run on the selection.
- nullindividual 2y agoI've done this to strip Exif metadata from pictures using Automator. Uses homebrew and the exiftool package. Workflow receives current "image files" in "any application" Image = Action Run shell script: Shell: /bin/zsh Pass input: As argument for f in "$@" do /opt/homebrew/bin/exiftool -all= -tagsfromfile @ -ColorSpaceTags -Orientation $f done ---- Will be under the Quick Actions menu. I tried the same with Shortcuts, but I cannot get it to run from the context menu, only within Shortcuts during testing. Maybe something limiting shell command access from Shortcuts? Not sure.
- msephton 2y agonice use case!
- lelandfe 2y agoThe built in "Convert Image" Quick Action has a Strip Metadata option
- nullindividual 2y agoThanks! However, it lacks a couple of things the Automator script does. It wants to convert by default to JPEG instead of keeping the source format, it requires interactivity, and for some reason if I cancel the dialog, I can't get it to run again without relaunching Finder (on 14.6).
- lelandfe 2y agoWow, can confirm that it silently dies if cancelled. Apple these days, huh?
- slmjkdbtl 2y agoHow come it doesn't run with Shortcuts? Any error message? I migrated all my context menu scripts from Automator to Shortcuts and have no problem
- 2y ago
- deleted 2y ago[deleted]
- mettamage 2y agoI sometimes need a path name, so I have "Copy Path" in my context menu
- Tagbert 2y agoif you have the Path Bar visible in Finder you can right-click on the folder name and choose "Copy 'X' as pathname". Works to copy any parent folder name, too. That's built-in and doesn't require any setup.
- Doctor_Fegg 2y agoYou can also drag the folder into Terminal to insert the path at the current cursor, or cmd-drag it into Terminal to do a `cd` to that path.
- msephton 2y agoHold down the Option key and the normal Copy changes to Copy as Pathname (aka Full Path). I use this almost every day.
- samatman 2y agoBless you for this. I even do Option-click things, and somehow, I never spotted that one.
- ctippett 2y agoBetterTouchTool also includes functionality to customise Finder's context-menu. I was hoping Hammerspoon would have something similar in their arsenal of APIs, but it doesn't look like they do.
- msephton 2y agoNice tip, thanks!
- slmjkdbtl 2y agoI've been using context menu quick action for a while [0] and they hugely improve my productivity. A few of my most used ones: - Search Image (search selected image through google lens) - Compress Images (compress selected images with jpegoptim or pngquant) - Open In Terminal / Vim (open selected directory in terminal / selected files in Vim) - Merge Subtitles (merge .srt subtitles into video files) Also discovered it's very useful to enable the preview panel in Finder (View -> Show Preview or cmd+shift+p) because it has 3 slots for quick action, much faster than going to context menu. Also for showing output, you can use osascript -e "display notification \"Message Here!\" with title \"Title Here!\"" [0] https://github.com/slmjkdbtl/rc/tree/master/shortcuts https://github.com/slmjkdbtl/rc/tree/master/shortcuts (shame that the .shortcut files aren't text based like automator files, no easy way to preview)
- msephton 2y agoThanks for sharing!
- jwells89 2y agoSemi-related, for devs who want to add Automator actions to their apps for users to make context menu items with, a while back I wrote a blog post and created a template that works with modern Xcode, since Xcode can no longer create them out of the box. https://wells.dev/creating-an-automator-action-in-2023/ https://wells.dev/creating-an-automator-action-in-2023/
- MemphisTrain 2y agoI do this on linux (dolphin) https://i.imgur.com/9C52czz.jpeg https://i.imgur.com/9C52czz.jpeg
- outworlder 2y agoFor parallel execution, instead of sending things to the background, we can use GNU Parallel – https://www.gnu.org/software/parallel/ https://www.gnu.org/software/parallel/
- msephton 2y agoMy attempt: convert_file() { f="$1" /opt/homebrew/bin/ffmpeg -i "$f" "${f%.*}.mp4" } export -f convert_file parallel convert_file ::: "$@"
- hirvi74 2y agoThe only use I ever get out Automator is basically just recording my actions, and then copying the actions into Script Editor in order to convert the actions to AppleScript. I wish Swift could replace AppleScript, but that is asking for too much. I dread the day AppleScript is not longer supported. Shortcuts is way too limited in my experience.
- rcarmo 2y agoI just use Shortcuts: https://taoofmac.com/space/notes/2024/02/22/1900 https://taoofmac.com/space/notes/2024/02/22/1900 The ones on the blog post appear as services because the take text, but I have others that work on files as Quick Actions.
- msephton 2y agoVery nice! Thanks for sharing.
- iAkashPaul 2y agoMore than this pressing spacebar should have gotten some customisation by now, eg. certain mp4s/markdowns/any other file-extension for quick previews
- msephton 2y agoYou can install your own QuickLook plugins to handle those, and more. I found all the ones I use on GitHub: QLVideo, qlmarkdown/QLCommonMark, qlstephen, etc https://github.com/haokaiyang/Mac-QuickLook https://github.com/haokaiyang/Mac-QuickLook
- sunny_sigara 2y agoBetterTouchTool now can add Finder context menu (at root and submenu level + icons). Check this out https://maverickmac.github.io/2024-07-28/finder-context-menu-with-btt https://maverickmac.github.io/2024-07-28/finder-context-menu...