Using TextExpander to Get Information About Your Mac
I use a lot of different pieces of software. And a lot of times that software is still in development. As a consequence, I run into a lot of bugs. The best thing to do when you find a bug is to reproduce it (to confirm that it’s actually a bug) and then contact the developers of the app so they can take a look at it and hopefully find a fix. When I do contact developers I like to give them as much information as possible. In addition to information about the app I’m having a problem with I also like to include the hardware information of my machine. This can be very helpful to developers in trying to pinpoint the source of a bug because sometimes weird things only occur on certain hardware configurations.
Ok, while sending that information is great but it’s often quite a chore to type out. To solve that problem, TextExpander (TE) is the natural choice. TE lets you type short ‘snippets’ of text and have it expand into basically whatever you want. For example, I have a snippet to expand into my signature that I use for emails. All I have to do is type ssig and that text expands into this:
Matthew Janssen
-----------
mjanssen2009@gmail.com
about.me/mjj
And my email address and web address even become rich-text links that can be clicked.
Back to printing system information. I first started with deciding what I wanted to print. I wanted to include the model of my Mac, the OS version I’m running, and information about my processor, graphics, hard drive, and memory. Here’s the finished product:
Model: MacBookPro9,2
OS Version: OS X 10.8.3 (12D78)
Processor: 2.5 GHz Intel Core i5
Graphics: Intel HD Graphics 4000 512 MB
Storage: APPLE SSD SM128E Media
Memory: 8 GB
Sure, I could create a snippet that has all of that information hard-coded in but that wouldn’t make the snippet very portable. I have multiple Macs so if I wanted to move this snippet to another Mac, I’d have to go in and change all that information. Not to mention that every time Apple updates OS X the OS Version line will need to be changed. I’m using a computer so why not take advantage of that and have the computer pull that information each time the snippet is run so it’s always current? That’s exactly what I did.
First, I needed to get each piece of information about the computer. TE is robust enough that it can actually run scripts instead of just expanding text when snippets are typed. These shell scripts will get the most current information off from the System Profiler. Here’s an example of the script used to get the Model of the computer:
#!/bin/bash
system_profiler SPHardwareDataType | awk -F: '/Model Identifier/ {gsub(/^[ \t]+|[ \n]+$/, "", $2); printf "%s", $2}'
You really don’t need to understand the inner workings of the script, just know that what it gives me is MacBookPro9,2. I created ‘shell snippets’ for each piece of information I needed and saved those in TE.
Finally, we get to the actual text we want to print when we type our snippet. TE also allows snippets to be used within snippets. So instead of using each of the snippets for the information we want separately and directly, we’ll use them through just one snippet. That snippet is below.
Model: %snippet:modelid%
OS Version: %snippet:sysvers%
Processor: %snippet:procspd% %snippet:procname%
Graphics: %snippet:grchip% %snippet:grvram%
Storage: %snippet:stormedia%
Memory: %snippet:mmemory%
This is an actual text snippet. So, for the first line, ‘Model: ’ is printed and then the %snippet:modelid% tells TE that another snippet needs to be run. This is the snippet we set up earlier to get the Model of the computer. That snippet is a shell snippet and when its done, MacBookPro9,2 will be printed in that space. This happens for the rest of the text in this snippet and what we end up with is what we saw earlier.
Model: MacBookPro9,2
OS Version: OS X 10.8.3 (12D78)
Processor: 2.5 GHz Intel Core i5
Graphics: Intel HD Graphics 4000 512 MB
Storage: APPLE SSD SM128E Media
Memory: 8 GB
The snippet takes a few seconds to run because each of those shell scripts have to chew through quite a bit of info. So, it takes longer than it would to expand if we had just hard-coded the information into a text snippet, but we have the advantage of being able to use this group of snippets on any Mac and it will grab the right information!
I’ve exported the folder of snippets and uploaded them to my Droplr account so anyone can grab them. To use it just import the folder into TE and whenever you type compinfo and the snippet will expand.
Download: Computer Info.textexpander
Notes
-
josselog likes this
-
smilinbrian reblogged this from matthewjanssen and added:
Contains a nifty system info/system details snippet.
-
pingviini42 likes this
-
peroty likes this
-
matthewjanssen posted this