Categories
Archived Design Uncategorized

HTML5 Boilerplate – Quick setup script

Recently I’ve been setting up new websites left, right and center.  These have been almost exclusively for testing purposes and, since I’ve been basing them all off Paul Irish’s HTML5 Boilerplate, I needed a quick way to get a new site template up and running.

Enter automation

I set about making a quick script to automate the process of setting up a new website template based on the boilerplate (which I’ll refer to as h5bp from here on).  The steps it goes through are as follows (Bash-specific but could be retro-fitted to Windows without too much trouble).

  • Checks to see if git is installed.  This is required as the latest h5bp version is available from github.
  • If git isn’t installed, the script will fail gracefully and provide instructions on how to install git.

      • Checks for a single parameter.  If found, the script will use this as the name of the directory to create the project in, relative to “.”
      • If no parameter is specified, the destination folder is setup to a folder named after the current date and time.
      • Checks to see if the destination folder exists (almost impossible if using the date and time method).  If it’s not found, it is created.
      • Initialises a new git local repository in the new project directory.
      • Clones the latest h5bp version into the project directory.
      • Clones the latest h5bp ant build script into the project directory,
      • Cleans up the directory structure a bit, e.g. renames the ant build script from “ant-build-script” to “build”  I’ve found this to be a required step before the build script will run properly.
      • Converts the h5bp markdown documentation to HTML, if pandoc is found on the local system.
      • Does a bit more cleanup and moves some non-critical files into a directory called “_exclude”
      • Configures some global git options, i.e. the user name and user email address.
      • Adds all the project files to the new git repository.
      • Does a full commit of the new files.
      • Finishes up with a small message showing some steps that may be helpful to new users.

    Care to share?

    Sure.  If you’re interested in the script, here it is in its entirety.  On my system I have it installed as an alias by putting into ~/.bash_profile inside a function called h5bp.  If you want to use the script in a stand-alone way, that works fine, too.  For the purposes of this article, I’ll show the code in its function-based form.

    The script

     # function to create a new website based on the HTML5 BoilerPlate (http://h5bp.com) function h5bp { if [[ -z `which git` ]]; then echo " The git binaries were not found on this system and are required before this script will run properly." echo " If you are sure git is installed, please investigate why the 'git' command wasn't found, then try again." echo " To do this, you can try running "echo `which git`" (without the double quotes but keep the single ones!)." echo " If you don't have git installed, please download and install it by following the instructions located at http://git-scm.com/download." else echo "git binary found at `which git`." echo "Creating new website." if [ -z $1 ]; then newFolderName=`date +%Y-%m-%d_%H-%M-%S` echo "No folder name specified, using current date and time: $newFolderName." else newFolderName=$1 echo "Using '$newFolderName' as destination folder." fi if [ ! -d $newFolderName ]; then echo "Destination folder not found, creating it now." mkdir $newFolderName cd $newFolderName else cd $newFolderName fi echo "Initialising new git repository in `pwd`." git init --quiet echo "Getting latest h5bp build from github." git clone https://github.com/h5bp/html5-boilerplate.git echo "Getting latest h5bp build script." git clone https://github.com/h5bp/ant-build-script.git echo "Moving files into place." mv html5-boilerplate/* ./ rm -Rf html5-boilerplate/ mv ant-build-script/ build/ mkdir _exclude/ if [[ -z `which pandoc` ]]; then echo "Unable to convert the readme.md file to HTML for viewing. You can fix this by installing 'pandoc' from http://johnmacfarlane.net/pandoc/." else echo "Converting markdown documentation to HTML." pandoc readme.md -o readme.html mv readme.html _exclude/ fi mv readme.md _exclude/ echo "Setting git global options." git config --global user.name "Put your name here" --quiet git config --global user.email you@yourdomain.com --quiet echo "Adding new files to new git repository." git add * echo "Running initial project commit." git commit -m "Initial h5bp project creation" --quiet echo "" echo "You should edit humans.txt in the '$newFolderName' directory before going any further." echo "Also, if you're not familiar with how to use the h5bp, you should go through the readme file in the _exclude/ directory (readme.md, or readme.html if you have pandoc installed)." echo "" echo "Done!" fi } 

    Can we see it in action?

    Of course you can.  I’ve recorded the script in action and put it up on YouTube – see below.  To view the video in HD so that your viewing experience doesn’t suffer from small-video-itis, I’d highly recommend watching it on the YouTube website (opens in a new window).

Categories
Archived Software Uncategorized

Set network interface IP address with Powershell

The Problem

While setting up our partner technology centre recently, I found myself switching back and forth between networks so often that I was constantly having to change my laptop’s IP address. For reasons that are outside the scope of this article I’m unable to use the option for an alternate network configuration.

Powershell to the rescue

The solution? Two small Powershell scripts – one to setup my network connection for our corporate LAN, the other to setup my network connection for the PTC. The scripts are shown below – feel free to use them in any way you like.

PTC configuration script {#ptcconfigurationscript}

 $index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq “Local Area Connection”}).InterfaceIndex $NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index} $NetInterface.EnableStatic(“10.0.0.10”, “255.255.255.0”) $NetInterface.SetDynamicDNSRegistration(“FALSE”) 

Corporate LAN configuration script

This script just resets the network adapter back to DHCP

 $index = (gwmi Win32_NetworkAdapter | where {$_.netconnectionid -eq “Local Area Connection”}).InterfaceIndex $NetInterface = Get-WmiObject Win32_NetworkAdapterConfiguration | where {$_.InterfaceIndex -eq $index} $NetInterface.EnableDHCP() $NetInterface.SetDynamicDNSRegistration(“TRUE”) 

Extra stuff

Although I don’t need them in my PTC environment (it’s internal only, with no internet access), you can also use the snippets below to add some extra functionality. Set gateway:

 $NetInterface.SetGateways($gateway) 

Set DNS server search order:

 $NetInterface.SetDNSServerSearchOrder($dns) # (e.g. “10.10.1.1” for single server or “10.10.1.1,10.10.1.2” for multiple servers) 

Enable dynamic DNS registration (e.g. in AD environment):

 $NetInterface.SetDynamicDNSRegistration($registerDns) 

Categories
Archived Mac & OS X Uncategorized

Getting Hazel for Mac to process subfolders

Back in February 2011 I wrote an article called Running HandBrakeCLI from Hazel that described how to setup Hazel for Mac to automatically run Handbrake from the command line. The idea of this is to run Handbrake automatically when a video file appears in a specific folder and convert the video to .m4v format suitable for iTunes.

This is a quick update to that post that shows how to setup Hazel to also process subfolders as, up until now, the Hazel configuration I had only processed a single level of folders.

The Hazel Rule

The configuration is pretty easy. Simply add a new rule at the top of your Hazel rules, making 100% sure it is above the rule that runs to automatically convert the video files.

The rule order looks like this:

Hazel rule order

Hazel rule order

The rule itself looks like this:

Hazel rule to process subfolders

Hazel rule to process subfolders

Once that rule is in place and the order is correct, the following rule will run once a new subfolder is found in the appropriate location.

Categories
Archived ExpressionEngine Uncategorized

Dynamic HTML grid with ExpressionEngine

Introduction

This article is going to be a long one so sit back, relax (if you can) and get ready to do some EE hacking … ok, not hacking, creation. 🙂

Assumptions

I’m going to make a few assumptions for this article, as follows.

  1. You know your way around the ExpressionEngine control panel and are familiar with terms like template, etc.
  2. You know what jQuery is have an idea of what it is used for.

The Situation

Recently I’ve been doing some work on the redesign of the website for Erin King Photographer. Part of the redesign is the requirement for Erin to do 99% of the site management herself, without the need to refer back to me.

I realised that I’d need absolute control over the layout, styling & site architecture for this to work – that meant WordPress wasn’t an option for this version of Erin’s site. Now, I’m not saying WordPress couldn’t do the job (we still run Erin’s blog part of the site on WordPress. In my opinion, though, WordPress forces a shift in focus from design to content management – good for some but not what I wanted.

The Desired Layout

It looks simple (and is, when rendered), but this is the layout we’re trying to get to. Don’t forget this must be built & rendered dynamically, not hard-coded in the page’s markup.

Dynamic HTML grid for displaying products
The desired layout

The Decision

Some time ago I decided the new site should run on ExpressionEngine. The ability to control absolutely everything and yet still have the power of a full CMS made the decision pretty easy (plus, Digital Formula runs on ExpressionEngine).

*cough* I’ll leave this article where it is, but Digital Formula runs on WordPress, now. 😉

The Problem

The first issue I ran into (which I knew was coming) was that ExpressionEngine’s native file module, while powerful in its simplicity, does lack a couple of what you’d expect to be standard features. For example, it’s difficult to control the order that files are displayed, unless they all have a different date and time in the database. It’s also impossible to manually set the file order in the control panel and have that order obeyed during page rendering.

Categories
Archived ExpressionEngine Uncategorized

ExpressionEngine Plugin – Entry Age

Today I threw together a quick plugin as I couldn’t find an easy way of doing what I wanted without putting JavaScript in my templates.  The plugin, called ‘Entry Age’, allows you to specify a message that can be displayed if the entry being viewed is older than a certain age.

Why a plugin?

I’m assuming that someone else out there will find this useful.  I’m sure plugins like this exist already but, if they do, I can’t find them.

For an example of what the plugin looks like when it finds an outdated entry, please see this article: Move ExpressionEngine to a different server (and yes, the content there is actually outdated).

Can I get it?

Of course you can.  If you want to download Entry Age and try it out, you can head over to my GitHub page any time. 🙂 Entry Age 1.0 on GitHub.

Hope it helps someone.

Categories
Archived Mac & OS X Uncategorized

Using PuTTY ssh keys on OS X

As part of helping a friend with some system support soon, I was sent a set of ssh keys so that I can access their Ubuntu servers.  The keys, however, are .ppk keys generated by PuTTY, the popular Windows SSH telnet/ssh client.

Unfortunately, the PuTTY keys don’t work for me as I’m using OS X … insert appropriate Mac-hating statement here, if you must.  😉  Needless to say, I had to find a way of using those keys so I could access the servers without any problems.

Fortunately for me, I’ve encountered this situation before.  While testing some connectivity issues recently I kept getting denied access.  The problem is that the keys need to be converted to OpenSSH format before they’ll work with command-line ssh in OS X.

To fix the issue, you’ll need PuTTYGen from the PuTTY website (don’t worry, it’s free).  If you don’t have it already, grab it, and follow the simple steps below (I’ll include the step to download, just in case you missed it).

Note: You’ll need access to a Windows machine for the below steps to work.

  1. Download PuTTYGen from the PuTTY website.
  2. Run PuTTYGen.exe, and open the .ppk file using the open option on the File menu.
  3. From the Conversions menu, export the key in OpenSSH format – it’s what you need for the key to work with OS X.

Once you’ve done all that, you should be able to run ssh from the OS X command line and connect without any problems.

Note: There are a ton of people who have experienced this issue and nearly every other website will tell you that you need to set the permissions on the .ssh file to 700.  In most cases 600 is enough.  If you don’t do this, you can receive an error like this one:

ssh Error
ssh Error

That’s all there is to it – easy.

Categories
Archived Software Uncategorized

SQL Server 2008 Express R2 Unattended Install

Back in March 2009 I wrote an article called "SQL Server 2008 Express Unattended Install"  It turned out to be one of the most popular articles on Digital Formula (and still is) so, since SQL Server 2008 R2 Express has been released, I figured I’d write an article refresh on how to do the same thing as the original article, but with the latest version.

To make the change easy, I’ll explain the main things that have changed between 2008 and 2008 R2 from an unattended install perspective.

Assumptions

  • You’ve already downloaded SQL Server 2008 R2 Express. This article will assume you’re installing the 32-bit (x86) version although I see no reason why the steps below won’t work with the 64-bit (x64) version.
  • Your system meets the requirements for installing SQL Server 2008 R2 Express.  Note that this includes installing the .NET Framework 3.5 SP1, Windows Installer 4.5 and Windows Powershell.
  • You are installing from C:InstallSQL2008 (you can change this as necessary but please make sure you update the paths in the examples below).
  • You’ll save your configuration file as C:Installsql-2008-express.ini

Extracting installation files

To get the extracted installation files, run the following command and follow the wizard – easy.  Note that I’ve extracted mine to C:InstallSQL2008Extracted.

C:InstallSQL2008SQLEXPRWT_x86_ENU.exe /x

Getting the default configuration file

This is the key difference between the previous version (2008) and this one (2008 R2).  Run the following command either from the command prompt or from the Start » Run dialog and then follow the steps below carefully – you’ll see that we don’t actually want to complete the install right now.

C:InstallSQL2008SQLEXPRWT_x86_ENU.exe /UIMODE=Normal /ACTION=INSTALL

This will start the installation with all parts of the installation visible.  If you just ran the executable, you wouldn’t see the screen that shows where the default configuration file is.

From here, follow the wizard, do a new install and configure the options as per your requirements, making sure that the steps on the left include the item "Ready to Install".  Note that this will only present if you ran the command above to set the UIMODE and ACTION parameters.

Ready to install option available
Ready to install option available
Categories
Archived Mac & OS X Uncategorized

Delicious bookmarks to Evernote using AppleScript

Over the last day or so I’ve been trying to find a decent alternative to Yahoo’s Delicious online bookmarking service.  It’s a service I’ve used for many years (since 2006, in fact) and, unfortunately, Yahoo has sold the service to AVOS.  To be fair, AVOS does plan to keep Delicious running and also implement improvements but with the purchase of an iPhone 4 it makes sense for me to transition to a service that I can synchronise between all my devices.

What is the chosen alternative?

I’ve been a long-time user of Evernote and its ability to sync between Mac (all my hardware), Windows (at work) and iPhone (in my pocket) makes it a sensible choice for the transition.  However, I needed to find a way to transfer all 2628 of my bookmarks to Evernote.

First attempt

My first go was to use the web service from Dr. Palaniraja but that didn’t do some of the things I needed.  For example:

  • It didn’t keep my tags, despite the website saying it would (this effectively made it useless for me)
  • It required a lot of manual input.  I don’t mind this so much but less technical users probably would.

I was looking for an automated way to transfer everything.  My chosen method is an AppleScript that I found online at Veritrope, which I then heavily modified to do more of the things I wanted.

My changes are as follows:

  • The original script verified every URL before adding it to Evernote.  Conceptually this is fine but I wanted to offer the option of not doing that.
  • The original script used the bookmark’s URL as the note title.  To me this is a little odd so I modified it to use the bookmark’s actual title as the note’s title, too.
  • The original script required some manual editing to set your location i.e. Japan, U.S. or outside Japan/U.S. I’m in Australia which meant manually changing the location.  This is easy but I wanted to prompt the user for this information.
  • The original script saved the bookmark’s entire page content as the content of the new note.  This is a great idea but I wanted the option of not doing this, if necessary.  The main reason for this is so that Evernote’s basic account holders don’t blow the cap on their monthly usage.
  • The original script, if verifying URLs, saved all the bad URLs to a single note.  I modified mine to save them as individual notes in a special, local-only, notebook called "Bad Bookmark List".

The script

Here’s the entire script.  All you need to do is:

  • Export your bookmarks from Delicious using their export/download page.
  • Copy/paste the script below into AppleScript Editor (Mac only!) and run it.

The only manual change necessary, if required, is to change the name of the destination notebooks for the good and bad bookmarks.  These two settings are evNotebook and badNotebook respectively.

Warning: Be aware that if you run this script over a big bookmark list and select to verify URLs, it may take a long time to run!

-- v1.30
-- http://veritrope.com
-- Delicious Bookmark Importer for Evernote
-- February 18, 2011
-- Status, Latest Updates, and Comments Collected at:
-- http://veritrope.com/code/delicious-bookmark-importer-for-evernote/
--
-- v2.0
-- June 14th, 2011
-- Chris Rasmussen, digitalformula.net
-- Changes:
-- Added prompt for verifying URL
-- Added prompt for saving notes with actual title as title or URL as title
-- Added prompt for location i.e. U.S. or Japan or everywhere else
-- Added prompt for saving the bookmark or full page as the note's content (recommended for Evernote premium users, only)
--
-- Note : The above prompts would usually be too many but since this script is probably intended to be run once only,
-- more options are better than none
--
-- v2.1
-- June 14th, 2011
-- Chris Rasmussen, digitalformula.net
-- Changes from 2.0:
-- Bad bookmarks are now added to a notebook called 'Bad Bookmark list' (createNote method changed to allow that)

-- *** Make changes in this section, only ***

-- title for dialog prompts
property scriptTitle : "Import Delicious bookmarks into Evernote"
-- set the variable below to the name of the Evernote folder to use for imported bookmarks
property evNotebook : "Delicious Import"

-- note for bad bookmarks - local only (won't be synchronised!)
property badNotebook : "Bad Bookmark List"

-- *** Stop editing here, please :) ***

-- firstly, create the 'bad' notebook
-- we do this now because otherwise AppleScript will, by default, create a synchronised notebook (bad idea if heaps of your bookmarks are invalid)
-- also, an error will be thrown if the notebook already exists - to prevent that, we do a quick check to see if a matching notebook can be found
tell application "Evernote"
	if (not (notebook named badNotebook exists)) then
		create notebook badNotebook with type local only
	end if
end tell

-- prompt the user for their location
global formatDates
property locationOptions : {"U.S.", "Japan", "Outside Japan/U.S."}
set location to (choose from list locationOptions with prompt "Please choose your location:" with title scriptTitle) as string

if location = "U.S." then
	set formatDates to "YES"
else if (location = "Japan") then
	set formatDates to "JP"
else
	set formatDates to "NO"
end if

-- verify URLs?
-- if the user responds in the affirmative, all URLs will be verified as working before they're added as notes
-- if the users responds in the negative, URLs are not verified and will be added even if they don't work
global verify
property verifyOptions : {"Yes - Verify all URLs", "No - Just import everything"}
set verifyResult to (choose from list verifyOptions with prompt "Verify URLs before import?" with title scriptTitle) as string

if verifyResult = "Yes - Verify all URLs" then
	set verify to true
else
	set verify to false
end if

-- use bookmark title or URL as new note's title?
-- the original script added notes with the bookmark's URL as the note title
-- this will allow the user to keep this option, if they like, or have the notes' title as the bookmark title (better, in my opinion)
global titleType
property titleOptions : {"Use bookmark's URL", "Use bookmark's title"}
set titleResult to (choose from list titleOptions with prompt "Use bookmark URL or title as note title?" with title scriptTitle) as string

if titleResult = "Use bookmark's URL" then
	set titleType to "url"
else
	set titleType to "title"
end if

-- save the page's full content as the note's content?
-- if the user responds in the affirmative, the page's entire content will be scraped and saved as the note's body
-- this is recommended for Evernote premium users, only
global contentType
property pageOptions : {"Yes - Save full page", "No - Save summary only"}
set pageResult to (choose from list pageOptions with prompt "Save full page as note's content?  This is recommended for Evernote premium users or small bookmark lists, only" with title scriptTitle) as string

if pageResult = "Yes - Save full page" then
	set contentType to "full"
else
	set contentType to "summary"
end if

property linkList : {}
property theTags : {}
property linkExists : ""
property badList : {}

-- Main program begins

-- reset items
set AppleScript's text item delimiters to ""
set linkList to {}
set badList to {}

-- select the Delicious export file
set deliciousFile to (choose file with prompt "Choose Delicious Bookmark Export File")

-- open the Delicious export file
set deliciousData to read deliciousFile
set deliciousBody to my extractBetween(deliciousData, "<dl>", "</dl>")

-- get a list of all the links
set delDelimiter to "<dt>"
set deliciousRAW to read deliciousFile using delimiter delDelimiter
my processLinks(deliciousRAW, linkList)

-- process each link into a seperate webclipped note in Evernote, keeping tags and dates intact
my evernoteImport(linkList, theTags)

-- add bad links to a note containing all the bad URLs
if badList is not {} then

	set old_delim to AppleScript's text item delimiters
	set AppleScript's text item delimiters to return
	set badList to badList as text
	set AppleScript's text item delimiters to old_delim
	set badLinks to "List of URLs Returning Errors: " &amp; return &amp; (current date) &amp; return &amp; return &amp; badList as Unicode text

	tell application "Evernote"
		create note with text badLinks title "List of URLs Returning Errors" notebook evNotebook
	end tell
end if

-- child methods

-- get the anchor href info
on processLinks(deliciousRAW, linkList)
	repeat with i from 1 to (length of deliciousRAW)
		set theItem to item i of deliciousRAW
		if theItem contains "A HREF" then
			set end of linkList to theItem
		end if
	end repeat
end processLinks

-- process each link
on evernoteImport(linkList, theTags)
	repeat with i from 1 to (length of linkList)
		set theItem to item i of linkList
		set theURL to my extractBetween(theItem, "A HREF="", """)
		set linkExists to "true" as boolean
		set epochseconds to my extractBetween(theItem, "ADD_DATE="", """)
		set deliciousTags to my extractBetween(theItem, "TAGS="", """)
		set itemTitle to my extractBetween(theItem, "">", "</A>")
		-- change the delimiters to parse tags
		set oldDelims to AppleScript's text item delimiters
		set AppleScript's text item delimiters to ","
		set theTags to text items of deliciousTags as list
		-- change the delimiters back to what they were before
		set AppleScript's text item delimiters to oldDelims

		-- if the user selected to verify all URLs, the URL will be verified here
		if verify then
			my verify_Link(theURL)
		else
			set linkExists to true
		end if

		if linkExists is not false then
			-- add the bookmark to the good list
			if titleType = "title" then
				my createNote(itemTitle, theURL, theTags, epochseconds, evNotebook)
			else
				my createNote(theURL, theURL, theTags, epochseconds, evNotebook)
			end if
			set theTags to {}
		else
			-- add the bookmark to the bad list
			if titleType = "title" then
				my createNote(itemTitle, theURL, theTags, epochseconds, badNotebook)
			else
				my createNote(theURL, theURL, theTags, epochseconds, badNotebook)
			end if
			set theTags to {}
		end if

		if verify then
			-- delay is only required if we're verifying all links
			delay 3
		end if

	end repeat
end evernoteImport

-- verify working URL, if required
on verify_Link(theURL)
	try
		set the_page to do shell script "curl -siL "" &amp; theURL &amp; """
		set the_code to items 10 thru 12 of the_page as string
		if the_code is greater than 400 then
			set linkExists to "false" as boolean
			copy theURL to the end of badList
		end if
	end try
end verify_Link

-- create the note
on createNote(itemTitle, theURL, theTags, epochseconds, notebookName)
	tell application "Evernote"
		try
			set createDate to my epoch2datetime(epochseconds)
			-- create the note based on user's choice of summary or entire page content
			if contentType = "full" then
				-- save entire page (this is the original script)
				set n to create note from url theURL created createDate notebook notebookName tags theTags
				set source URL of n to theURL
			else
				-- save summary only (new option, good for Evernote basic account holders)
				set n to create note title itemTitle with text theURL created createDate tags theTags notebook notebookName
				set source URL of n to theURL
			end if
		end try
	end tell
end createNote

-- convert UNIX epoch time
on epoch2datetime(epochseconds)
	-- adapted from script found at Erik's Lab (http://erikslab.com/2006/09/05/how-to-convert-an-epoch-time-to-a-meaningful-date-and-time/)
	set myshell1 to "date -r "
	if formatDates is "YES" then
		-- formatted for U.S.
		set myshell2 to " "+%m/%d/%Y %l:%M %p"" -- Formatted for U.S.
	else if formatDates is "JP" then
		-- formatted for Japan
		set myshell2 to " "+%Y/%m/%d %l:%M %p""
	else
		-- formatted for everyone outside Japan/U.S.
		set myshell2 to " "+%d/%m/%Y %l:%M %p""
	end if
	set theDatetime to do shell script (myshell1 &amp; epochseconds &amp; myshell2)
	return date theDatetime
end epoch2datetime

-- extract text between specified delimiters
on extractBetween(SearchText, startText, endText)
	set tid to AppleScript's text item delimiters
	set AppleScript's text item delimiters to startText
	set endItems to text of text item -1 of SearchText
	set AppleScript's text item delimiters to endText
	set beginningToEnd to text of text item 1 of endItems
	set AppleScript's text item delimiters to tid
	return beginningToEnd
end extractBetween

Thanks to Justin from Veritrope for the original idea.

Categories
Archived Mac & OS X Uncategorized

Pimp My Desktop using GeekTool

Continuing with the theme of pimping various aspects of the OS X system configuration, today’s article covers how to use GeekTool 3 to display useful info on your OS X desktop.  For those that missed it, one of my recent articles, "Pimp My Prompt … like Paul Irish covered using the .bash_profile script to add some geek bling to your bash prompt – check it out.

The idea of GeekTool is to use the often under-utilised desktop area of OS X to display useful info.  Some people use it to display images but most use it to run Bash shell commands to interrogate and display various system-level statistics.  For example, my desktop looks like this (click for larger version):

My GeekTool Desktop
My GeekTool Desktop

Before you ask, the desktop background is an InterfaceLift image called The Solutionist.  🙂

Now, I’m going to assume that you’ve already downloaded and installed GeekTool 3 from the GeekTool homepage.  If you haven’t done that already, do it now, please.

Once you’ve got it installed, open System Preferences and click the GeekTool preference pane that should now be available.  For this article, please drag a "Shell" Geeklet onto your desktop.  Configure it any way you’d like in terms of position – for the sake of comparison, the screenshot below shows the settings for my date and weather Geeklet.

Date and weather Geeklet settings
Date and weather Geeklet settings
Categories
Archived Linux Mac & OS X Uncategorized

A couple more BASH prompt examples

Yesterday I published an article called "Pimp My Prompt … like Paul Irish" in which I showed how to make your BASH prompt similar to the one used by Paul Irish.

I also included a couple of sample prompts that you could use for reference so I figured I’d write a follow-up article that shows what they look like.  So, without any further ado, here they are.

Example 1 – Green username, blue host, magenta working directory, white git branch:

PS1='${GREEN}u${BLACK}@${CYAN}h:${MAGENTA}w${WHITE}`__git_ps1 " (%s)"`$ ‘

The example above uses the short colour codes outlined in the original article and looks like the screenshot below.

Green username, blue host, magenta working directory
Green username, blue host, magenta working directory

Example 2 – Blue user and host, magenta working directory, white git branch:

PS1='[33[0;36m]u@h[33[01m]:[33[0;35m]w[33[00m][33[1;30m][33[0;37m]`__git_ps1 " (%s)"`[33[00m][33[0;37m]$ '

The example above uses the built-in colour codes but can be harder to read.  It looks like the screenshot below.

Blue user and host, magenta working directory, white git branch
Blue user and host, magenta working directory, white git branch

Don’t forget to read the original article, "Pimp My Prompt … like Paul Irish", if you’re unsure about how to enable the __git_ps1 and short colour code commands.