Textexpansion macro to create a UUID
This macro uses the uuidgen
terminal command to generate a UUID.
So when you type *uuid
it gets expanded to a unique identifier.
UUID.kmmacros (3.1 KB)
Textexpansion macro to create a UUID
This macro uses the uuidgen
terminal command to generate a UUID.
So when you type *uuid
it gets expanded to a unique identifier.
UUID.kmmacros (3.1 KB)
I needed to generate some UUIDs this evening, and uuidgen (as above) is a good clean solution.
Just in case it's ever useful in the context of Execute JavaScript for Automation or AppleScript actions, here are JXA and Applescript equivalents (bare one-liners in a sample macro, and wrapped as named functions in the source snippets below):
New UUID.kmmacros (18.4 KB)
(() => {
// GENERIC FUNCTION -----------------------------
// newUUID :: () -> IO UUID String
const newUUID = () =>
ObjC.unwrap($.NSUUID.UUID.UUIDString);
// TEST -----------------------------------------
return newUUID();
})();
use framework "Foundation"
use scripting additions
-- GENERIC FUNCTION -------------------------------------------
-- newUUID :: () -> IO UUID String
on newUUID()
current application's NSUUID's UUID's UUIDString as string
end newUUID
-- TEST -------------------------------------------------------
on run
newUUID()
end run