Created
October 9, 2017 02:17
-
-
Save kuku/a180711f5ee9beed0fce8c1a759c2436 to your computer and use it in GitHub Desktop.
Word and Character Count service for Mac OS X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Word and Character Count service for Mac OS X | |
-- Adds a Word and Character Count option to the text selection context menu | |
-- Use Automator to create a new service, then select the Run AppleScript action. Make | |
-- sure the service is set to receive "text", at the top of the window. Paste in this code | |
-- and save as "Word and Character Count". Now switch to a new app, select some text, | |
-- right-click, go to Services, and find the new option. | |
-- Copyright 2015, Noah Slater <[email protected]> | |
-- Copying and distribution of this file, with or without modification, are permitted in | |
-- any medium without royalty provided the copyright notice and this notice are preserved. | |
-- This file is offered as-is, without any warranty. | |
on run {input, parameters} | |
tell application "System Events" | |
set _appname to name of first process whose frontmost is true | |
end tell | |
set word_count to count words of (input as string) | |
set character_count to count characters of (input as string) | |
tell application _appname | |
display alert "" & word_count & " words, " & character_count & " characters" | |
end tell | |
return input | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment