Tag Archives: osx

Visualizing Directory Structures with the Tree Command

Sometimes good old ls just doesn’t cut it when you’re browsing directories from the command line. Sometimes you just need a more visual overview of the nested files and directories. Well, it turns out there’s a useful command for those cases, and it’s available for Linux, OS X, FreeBSD and just about any OS you can think of. (Except Windows, of course.) It’s called tree.

To install it on OS X, with Homebrew:

brew install tree

On Ubuntu/Debian, or other Linux distros that use Debian packages:

apt-get install tree

To use it, just navigate to a directory and type tree. It has various options (visible with tree --help), so you can limit how many levels down it will go, exclude items that match a pattern, adjust sorting, etc.. You get a spiffy diagram that looks something like this:

.
├── application.rb
├── boot.rb
├── database.yml
├── environment.rb
├── environments
│   ├── development.rb
│   ├── production.rb
│   └── test.rb
├── initializers
│   ├── backtrace_silencers.rb
│   ├── filter_parameter_logging.rb
│   ├── inflections.rb
│   ├── mime_types.rb
│   ├── secret_token.rb
│   ├── session_store.rb
│   └── wrap_parameters.rb
├── locales
│   └── en.yml
└── routes.rb

Is that cool or what? This should be quite useful for writing tutorials, since a plain-text directory tree is more accessible than a screenshot of a file manager window.

4 Useful cURL Tricks

cURL is pretty much the universal go-to tool for testing HTTP responses from the command line. If you’re not already familiar with it, here are a few handy things you can use it for.

Checking Headers

You can use cURL to see the headers sent in a request. I use this all the time to see if the headers I’m trying to send in a script are working right.

$ curl -I http://www.google.com
HTTP/1.1 200 OK
Date: Thu, 06 Dec 2012 02:45:58 GMT
Expires: -1
Cache-Control: private, max-age=0
Content-Type: text/html; charset=ISO-8859-1
(...)

Sending POST Requests

I was working on a project recently that involved receiving POST requests from a client script running on another server. Since there was no convenient HTML form to use to repeatedly test changes made to the API, I ended up using cURL. Sending POST data is a simple matter of passing an argument that looks something like a query string.

curl http://example.org/url-to-recieve-post-request -d "name=Gandalf&type=wizard";

Continue reading →

FinderPath Extension for Alfred

I use Alfred for all of my application launching, number calculating and folder-finding needs. It usually does a good job at finding what I’m looking for, though sometimes you already have an exact file path in mind and want to jump right to it. One example is the Library folder. I find myself digging around in there regularly for whatever reason (retrieving Minecraft screenshots, diagnosing crashy apps, etc.) and it just takes too long to get there manually. Lion and Mountain Lion made it especially vexing, as it’s hidden by default. (And it re-hidden after each software update, even if you change the setting with a terminal command.)

So I made an Alfred extension that will open any supplied path in a new Finder window. No fancy searching, just a direct “open this.” It uses the standard “cd ~/Documents/GitHub” syntax experienced users of the command line will be familiar with. It even escapes spaces automatically.

Installation Instructions

  • Download the FinderPath extension
  • Unzip the archive and double-click the resulting FinderPath.alfredextension file
  • Alfred should do the rest

Fixing Slow Hosts File Lookups in OS X Mountain Lion

Mac users with custom entries in their /etc/hosts files may have noticed that, under Mountain Lion at least, lookup times for local resources are incredibly slow. I routinely set up names that point to virtual hosts on my laptop so I can give projects their own local domain instead of having http://localhost/projects/something/index.php or somesuch. Typing something.dev is much easier. I noticed that, since upgrading from Snow Leopard to Mountain Lion, Firefox would spend several seconds trying to look up those names before consulting the hosts file and loading the page.

While I don’t know why it’s happening, exactly, I do have a fix. The wait goes away if you put the local entries on one line.

Instead of having something like this:

#virtual hosts
127.0.0.1 myproject.dev
127.0.0.1 wordpress.dev
127.0.0.1 somesuch.dev

You need to have this:

#virtual hosts
127.0.0.1 myproject.dev wordpress.dev somesuch.dev

Leave the lines that say “localhost” alone, of course. Messing with those could cause all manner of Bad Things.

Syntax Highlighting in Mac OS X Quick Look

Starting in OS X 10.5, Apple introduced the handy Quick Look feature, which of course enables you to preview a file by tapping the spacebar. If you’re like me, you probably use it regularly for quick glances at files that you don’t really need to open in your text editor. But it lacks one thing, one thing that makes reading long source files bearable: syntax highlighting.

I can’t believe it took me so long to find it, but there is an extension for Quick Look that adds color coding to source files in most common languages. QLColorCode, as it is called, is compatible with every version of OS X from Leopard to Mountain Lion. You just drop the .qlgenerator file into ~/Library/QuickLook or /Library/QuickLook and enjoy your improved Quick Look functionality.

QLColorCode [Google Code]

MacRabbit isn’t Dead!

Users of Espresso and CSSEdit have been complaining for some time about the lack of updates to the software. In a surprise announcement, MacRabbit (the developer) announced that Espresso 2 is on the way and that CSSEdit’s functionality is being rolled into it.

The long wait has grated both on our own nerves and those of our awesome users. But while we have kept quiet publicly about what we are working on, it is because privately we have been striving to transform our products into something new and even more awesome: Espresso 2. We are extremely excited to finally be able to show you what we have been working on, as this release will be of interest to both CSSEdit and Espresso users.

An early preview, the “kaboom” release, is already available for testing and upgrade path information has been posted.

Lions and iClouds and iOS 5: WWDC 2011 Roundup

Too busy to watch the liveblogs of Apple’s big WWDC keynote? Here’s a quick rundown of some of the most noteworthy links. There’s a lot changing in iOS, and OS X Lion is just around the corner. Then there’s iCloud, the crazy service that does more than most speculated.

Apple to Announce iCloud, iOS5 and OS X Lion on June 6

Apple put out a press release that they will be unveiling a large batch of “next generation software” on June 6th at the World Wide Developer Conference. This will include iOS 5, Mac OS X 10.7 Lion and something known as iCloud.

CUPERTINO, California—May 31, 2011—Apple® CEO Steve Jobs and a team of Apple executives will kick off the company’s annual Worldwide Developers Conference (WWDC) with a keynote address on Monday, June 6 at 10:00 a.m. At the keynote, Apple will unveil its next generation software – Lion, the eighth major release of Mac OS® X; iOS 5, the next version of Apple’s advanced mobile operating system which powers the iPad®, iPhone® and iPod touch®; and iCloud®, Apple’s upcoming cloud services offering.

It is speculated that this press release, specifying exactly what will be covered at the keynote, is a stab at preventing the usual stock drop from disappointed speculators hoping for new hardware. (That will probably be in September.)

We already had a sneak preview of Lion last year, but this should be a look at the final product—as well as a release date. The big news will likely be iOS 5 though, with its rumored widgets and notification overhaul. iCloud is the big mystery—I’m thinking it will be some sort of storage and syncing API, integrated with iOS and Lion, for app developers to leverage.

Oh, and the iPad versions of the iWork apps are now available on the iPhone.

Caffeinated RSS Reader Beta Now Available

A couple years ago, I heard about an interesting Mac RSS reader in development. Caffeinated, as it was called, sounded like a good alternative to my current feed reader (NewsFire). There were some neat screenshots, but the software was nowhere near ready for release.

After much waiting, the developer has finally released a beta of the application.

It’s very fast, taking only a couple seconds to launch. The interface is slick, particularly the pane that displays the current feed item. Caffeinated does a very good job at formatting the text and resizing images to fit cleanly into the content.

Of course, Reeder is also being beta tested now. Since news of Caffeinated started circulating around the internet, some competitors have shown up. Reeder, in particular, stands out. It will be interesting to see which app comes out of beta first, and how users react.

Caffeinated RSS Reader for Mac Finally Out As Beta [Macstories]

Mac App Store Launches…Along With Tweetie 2 for Mac

Apple just launched the Mac App Store yesterday, bringing with it a welcome surprise. The much-awaited Tweetie 2 for Mac is finally available, in the App Store, under the new name of Twitter for Mac. I’ll get to that in a little bit, though. Let’s take a quick look at this App Store that everyone has either been impatiently waiting for or relentlessly fear-mongering about.

There it is. The Mac App Store has launched with a good selection of applications, and their prices range from free to reasonably priced to, on occasion, absolutely bizarre. There are plenty of wonderful free apps, such as Evernote, TextWrangler, Caffeine, StuffIt Expander, and Twitter. There are hit games like Angry Birds and Bejeweled 3.

Here’s the strange thing: LEGO Harry Potter the Videogame (from the same folks who made the fun LEGO Star Wars games) is available in the App Store for a whopping $49.99. Meanwhile, you can get it for Windows XP for about $20 on a disc. They’re charging about twice as much for a fully digital version. I don’t quite follow that logic.

Continue reading →

Page 1 of 212