There are numerous reasons you might need a unique identifier on something; you upload files with common names to the same ftp site, you use the id attribute for internal links on a blog that might display multiple posts (the chances of repeating yourself are good), you want to sign your emails with a unique, one time id for your own verification… Whatever the case, a unique id could come in handy.
The easiest thing to do is use a timestamp and a shell script can do that easily enough for us. For everyday use, the year, month, day, hour, minutes and seconds should suffice (unless you need multiple unique id’s per second). Here is how the bash script would look:
Entering this string into the Terminal.app would yield a twelve digit number like this:
The first pair of digits is the year, the second pair is the month, the third pair is the day, then the hour, minutes and seconds (all in pairs). Run this script in Terminal.app as many times as you like and you will never get the same number.
So you could enter this into your terminal every time you wanted a unique id… or you could make this shell script work *for* you from anywhere.
## TextMate Snippet ##
TextMate makes running shell scripts dead easy — all you need to do is create your own snippet. To do this:
* open your Bundle editor — `Bundles > Bundle Editor > Show Bundle Editor` ***or*** `⌃⌥⌘B`
* create a new bundle (if you don’t already have your own) from the + icon
* within that bundle create a new snippet from the + icon
* in the edit window, type:
* define a Tab Trigger or Key Equivalent
* leave the scope selector blank to have the snippet apply to all language types
Now you have a snippet that is accessible in any language scope you use TextMate for. This is handy if you write reference links in HTML articles, such as:
Or for reference style links in MarkDown:
Check out our site, [seyDoggy][a_091027194631], for some
really cool tips and tricks.
[a_091027194631]: http://www.seydoggy.com/ “seyDoggy’s really cool site”
### Download ###
Download your fresh copy of “[Unique ID.tmSnippet][a_091027205118]” from seyDoggy.com.
## AppleScript to clipboard ##
Say you’re not a TextMate user but you still want a quick way to run this shell script with as little effort as possible. AppleScript makes quick work of this task with it’s `do shell script` functionality. We need to make an AppleScript that runs the shell script, then copies the results to the clipboard. Then we can paste that result into what ever we’re working with at the time; file renaming, email signing, etc…
Here is how the script looks:
set uniqueID to (do shell script “date +%y%m%d%H%M%S”)
set the clipboard to uniqueID
display alert “\”" & uniqueID & “\”" & “Has been copied to your ¬
clipboard” giving up after 1
### Download ###
Get your fresh copy of “[UniqueID.scpt][a_091027205534]” from CodeCollector.net
[a_091027205118]: http://www.seydoggy.com/downloads/UniqueID.tmSnippet.zip “Download from seyDoggy.com”
[a_091027205534]: http://www.codecollector.net/view/55260B3D-599D-489A-BC7E-C51AF597B2D0 “Download from CodeCollector.net”
One thing the Mac OS has repeatedly failed at is a native clip board, one where more then the most recent item is available to you. This has been an ongoing concern of mine for quite some time and I have always been on the lookout for a solution… a good solution.
Back in the spring of 2007 I wrote about [iClip as one possible solution](http://www.seydoggy.com/2007/03/28/copy-and-paste-and-copy-and-paste/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”) and in fact my dependency on it around that time became so great that I was using it to store passwords, code snippets, oft used text, etc… All was great until one day, the database became corrupted. Yes, iClip was complex enough that is was storing all my clipboard data, snippets and what not, in a database. _Eeeeek!_
My next _notable_ shift in clipboard management was QuickSilver, [for which](http://www.seydoggy.com/2008/02/01/web-search-with-quicksilver-the-definitive-how-to/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”) [I have](http://www.seydoggy.com/2008/01/30/quicksilver-as-a-file-launcher/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”) [written numerous](http://www.seydoggy.com/2007/12/03/convert-icons-revisited/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”) [articles](http://www.seydoggy.com/2007/03/30/quicksilverhttp/ “seyDoggy Web and Graphic Design – seyDoggy weblog – my thoughts on the web and the mac”). For everything that I used iClip for I was able to use QuickSilvers “Shelf” and “Clipboard History”. It was a brilliant setup and had them show/hide off the edge of the screen with a couple hot-keys. Then came the inevitable fall of QuickSilver. I can’t afford to keep monkeying around with sub-alpha builds of various branches so after my nearly three year dependency on QuickSilver I had to finally give it up.
The hole that was left was quickly filled with apps that I already use on a daily basis, like [Code Collector Pro](http://www.mcubedsw.com/software/codecollectorpro “M Cubed Software – Code Collector Pro”) which bore the brunt of my oft used text snippets and auto complete tasks. But I was still left without a good solution for clip board history. So off on a mad search I went, review countless apps that varied in complexity and price range, until I came upon a small, simple, unobtrusive app that does one thing; buffers your clipboard history. [Jumpcut](http://jumpcut.sourceforge.net/ “Jumpcut: Minimalist Clipboard Buffering for OS X”) is a simple, open source (and free) clip board history manager that allows you easy access to your clipboard history with a few simple key strokes.
Jumpcut allows you to set up the size of your buffer size (up to 99 clips), hot keys, bezel behaviour, app behaviour and that’s about it. It doesn’t get any simpler to use or set up. I have been using this little app heavily on a daily basis since February and never once has it failed me. No hang ups, it’s never lost my history, it’s never crashed or caused anything else to crash. It’s lightweight, responsive and just an overall pleasure to use.
_This_ is the app that ought to be a part of Mac OS X.