Crafting a customized phrase depend service — Erica Sadun

Crafting a customized phrase depend service — Erica Sadun


I simply occurred to want to do loads of phrase counts at present so I put collectively a service to make my life simpler. Whereas, I carried out my preliminary work on Mojave however the identical method works all the best way to Large Sur and, presumably, the upcoming macOS Malibu Barbie.

Open Automator

To get began, launch automator and create a brand new doc.

Choose Fast Motion, Select from the brand new doc dialog:

Add Scripting

Drop in a Run Shell Script after which an Apple Script. You possibly can search from them within the top-left nook. Drag them so as into the correct panel.

I used /bin/bash for my shell script, surprising, I do know, as I’m well-known for my love of all issues csh. Be happy to make use of no matter shell fits you. The primary non-argument shell variable ($1 right here) corresponds to highlighted textual content, which can be utilized by the system contextual menu:

echo `echo $1 | wc -w` phrases. `echo $1 | wc -c` characters.

Swap the pop-up for piping output (“passing enter”) from “to stdin” to “as arguments”. This permits the AppleScript to learn the chosen knowledge and current a dialog. In the event you neglect, you’ll get empty enter and one thing like “1 phrases, 0 characters” on a regular basis.

on run {enter, parameters}
    show dialog enter as string buttons {"OK"}
finish run

Save and Run

Save the motion. I known as mine “Phrase Rely”.

Microsoft is Finally Removing the Fat32 Partition Size Limit in Windows 11

The motion routinely saves to ~/Library/Providers, in case you need to discover or delete it sooner or later.

% ls
Phrase Rely.workflow/

Your new fast motion routinely provides a customized service to your contextual pop-ups. Simply spotlight something you need to depend, from textual content on an online web page to your work in a doc and open the contextual menu:

Make certain the output appears cheap. For best testing, copy the textual content to your clipboard after which use wc immediately in terminal.

And, then growth, you’re executed.

Let me know if this was useful.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.