andyMatthews.net
Command line tools for the novice
I've always had a healthy skepticism about the command line. It seemed like too much magic in soo little typing. Watching my friend Matt Telnet into his mail server using PINE (Pine is Not Elm) instead of using AOL, the programmers at my first web job installing entire operating systems with just a few typed commands into a terminal window. And most recently the Rails dudes generating entire websites with a single cryptic line of code. It wasn't until I started using my MacBook for daily developing that my viewpoint really changed. Seeing the sort of quick configurations that were possible in the Terminal window really changed my mind about it, and now I guess you might say that I'm a junkie. This post is dedicated to sharing a few of the tools and commands I use daily that really improve my workflow and save me time.
iTerm2 - free
Any conversation about using the command line needs to start with a good terminal window. iTerm2 for the Mac is free and it's top notch. It supports tabbed interfaces, split panes, multiple profiles (different settings depending on what you're doing), and bookmarks. You can style and color it any way you like, and when used in conjunction with the next tool it really makes your command line environment unique.
Zsh - free
The command line is the entry point into the inner workings of your computer, and the doorway is your "shell". There are a number of different shells available and their use is generally based on personal preference. The Mac OS defaults to the Bash shell, but there's a better option: ZSH. ZSH acts very much like the Bash shell so you'll feel right at home. But right away you'll start noticing subtle improvements. Zsh will correct commonly misspelled words and commands. Its tab-completion not only shows you what's available but allows you to choose it using the arrows (or just continue pressing tab)! Zsh will share your command history across multiple terminal windows. There's lots more, but since Zsh is free and easy to install, you should check it out. But before you do, read through the next item, as there's an easier way...
Oh My Zsh - free
Oh My Zsh is a set of community managed tools for use with Zsh. It includes a lengthy list of plugins and themes that will really make Zsh sing. Plus, if you install Oh My Zsh using Git, it'll automatically set up Zsh for you. Two for one! Not a bad deal. Oh My Zsh is a no brainer if you've decided to give Zsh a try.
Z - free
Not to be confused with Zsh or Oh My Zsh, Z is a simple command line utility that does one thing, and does it very well. Z runs in the background and records every directory that you cd into. It then compiles a weighted list of the most frequently (and recently) used and presents them to you. Tired of typing cd ~/Sites/clients/google.com/search/ all the time? Cd into that directory enough times and you'll be able to type any part of the path after "z" and jump straight there. z search and you're there baby!
Ack - free
Ack is a command line tool which allows you to sift through files and folders for your desired search term. If you're already familiar with grep, then you can use Ack with zero additional effort. Ack is fast, flexible and offers a better set of default functionality than Grep. For example you want to search through all the files in your website for a CSS class name. In Grep grep -R 'some term' *, in Ack ack 'some term'. The -R tells grep to search through all directories and subdirectories while the * tells it what types of files. Yes, it's only a few characters, but time is money...plus Ack is 4 or 5 times faster than grep.
cURL - free
cURL is included with OS X and it's an excellent utility which lets you interact with URLs via the command line. You can grab the contents of a JavaScript file and save it to your local machine:
curl http://www.google.com/search.js -o /path/to/local/file.js
Or you could get your remote IP address:
curl ifconfig.me
You can even GET/POST to a URL using cURL
server - free
Thanks to Paul Irish for this one. This is a handy function that you can run that starts up a simple Python web server in the current directory. It's a quick way to view files in a server's context and not have to worry about your browser complaining about loading local files. On a side note, this video with Paul Irish is an excellent example about being in love with the tools you use.
function server() {
local port="${1-8000}"
open "http://localhost:${port}/"
python -m SimpleHTTPServer "$port"
}
So there's 7 for you, but there's an almost unlimited number of other tools and utilities out there that can improve efficiency, workflow, and save your sanity. If you've ever thought "there must be a better way", then there probably is. Go forth and find it!