A little hack to make life easier on your Mac

HTTP head with curl

When working I'm checking HTTP headers from different services and websites frequently. To make this as painless as possible I've made a small hack for myself.

Make a small bash script called head.sh and save it in your ~/:

#!/bin/bash
curl -s -D - $1 -o /dev/null

Add an alias inside your ~/.bashrc file:

alias HEAD='~/head.sh'

To apply your changes in your current terminal window, source the .bashrc file:

$ . ~/.bashrc

Now you're good to go. Test your new command:

$ HEAD vg.no
HTTP/1.1 301 Moved Permanently
X-VG-WebServer: vgphoenix-web-01
Location: http://www.vg.no/
Content-Type: text/html; charset=iso-8859-1
X-VG-SolveMe: uggc://jjj.it.ab/ynxfrgngg.ugzy
Transfer-Encoding: chunked
Date: Sun, 01 Mar 2015 08:49:19 GMT
Connection: keep-alive
X-Cache: HIT:77
Server: Commodore 64
Vary: Accept-Encoding,User-Agent
X-VG-WebCache: m323-varnish-02
X-Age: 121
Age: 0

Next time you are opening a new terminal you are able to use your new command HEAD.