Many a time, when I write for publications, I need to constantly limit myself to a certain number of words. I also need to keep a track of the same while designing websites, or copyediting someone else’s articles. I know that there are apps like Ulysses and Draft that monitor the same, but it becomes a hassle to copy and paste text when I am working on other applications. To mitigate that constant irritation, I decided to write an Alfred workflow and automate this task. I’ve bound the workflow to the keyboard shortcut cmd+ctrl+B
. The moment the workflow is triggered, Alfred passes the text I have selected to the workflow and calculates the number of words using a bash script.
Here is a demonstration of how this works.
The Script
Here’s the Bash script I used to calculate the number of words.
input="{query}"
words=( $input )
echo ${#words[@]}
The Workflow
Here’s the Alfred workflow that you can download and import into your Alfred setup to start using it.
It is also possible to trigger the workflow by simply typing count
on Alfred search bar after copying the text into the clipboard.