this post was submitted on 09 Jan 2025
30 points (89.5% liked)

Apple

17785 readers
114 users here now

Welcome

to the largest Apple community on Lemmy. This is the place where we talk about everything Apple, from iOS to the exciting upcoming Apple Vision Pro. Feel free to join the discussion!

Rules:
  1. No NSFW Content
  2. No Hate Speech or Personal Attacks
  3. No Ads / Spamming
    Self promotion is only allowed in the pinned monthly thread

Lemmy Code of Conduct

Communities of Interest:

Apple Hardware
Apple TV
Apple Watch
iPad
iPhone
Mac
Vintage Apple

Apple Software
iOS
iPadOS
macOS
tvOS
watchOS
Shortcuts
Xcode

Community banner courtesy of u/Antsomnia.

founded 2 years ago
MODERATORS
 

I was looking for a way to sort a selection of text lines (specifically in Xcode, which doesn't have a builtin way to do this) today. Thinking this wasn't possible at all and I'd have to use another editor (such as BBEdit which has a menu entry for this), I looked it up online.

And what do I find: https://stackoverflow.com/a/8104750

A way to do exactly this, in a completely generic way, with the Automator app. Allows you to run any program over selected text in any application, plus of course other Automator actions. Super cool, both for the user of course and also for app developers because they don't need to take the effort replicating features like this in every single app that is text editor adjacent.

I definitely need to look into Automator more.


Rant:

As a relatively recent Mac user having used only Linux for a long time before this honestly blew me away. This level of integration is unthinkable under Linux until now, and people usually point to this kind of thing being "impossible" as a reason for using the terminal extensively as opposed to graphical programs. But no, turns out, it is completely possible if your graphical environment has a solid foundation and isn't just a hodgepodge of mostly questionable UI toolkits (not you, Qt Widgets) with the only common interface being "you can open a window and get a framebuffer to draw on".

top 6 comments
sorted by: hot top controversial new old
[–] [email protected] 13 points 2 weeks ago
[–] [email protected] 11 points 2 weeks ago (2 children)

AppleScript really is amazing and I'm surprised Apple doesn't publicize it more. There's nothing like it.

[–] [email protected] 2 points 2 weeks ago* (last edited 2 weeks ago)

Apple has too many automation and extensions tools:

  • AppleScript has been around for decades
  • Services in the Service menu inherited from NeXTStep
  • Automator actions
  • Share menu ported over from iOS
  • Shortcuts App ported from iOS

Apple only advertises the newest of those: Shortcuts

[–] cybersandwich 1 points 1 week ago

IMO this is where Apple Intelligence could really shine. Imagine asking siri to do a semi complex task and have it create an apple script/shortcut/automation for it without having to know anything about how it works. Talk about a killer feature.

[–] [email protected] 5 points 2 weeks ago

Yeah, I have some Python scripts that reflow selected passages of code for me using this approach. It always feels so weird when I'm using some OS that seemingly doesn't support any sort of GUI scripting.

It's worth noting that while you can simulate mouse clicks and key strokes within any app, some support a few direct scripting commands. For example, in Terminal, you don't need a GUI script to open a new window and type in it to run some command. You can just issue an AppleScript command to tell app "Terminal" to do script "top" or whatever. That's because Terminal's scripting library includes a do script command.

For more on this, you can fire up Script Editor and go Open Dictionary. You will see a list of all apps with any sort of scripting support and be able to get documentation on what you can do with it.

[–] [email protected] 2 points 2 weeks ago

MacOS has great power user features in general. pbcopy and pbpaste in the terminal are super useful. You can also change the shortcuts of menu items for all applications in syatem settings. Sadly this doesn’t work for Electron and some cross platform applications. Many of those even forgot putting commands in a menu in the first place.