macbook - low power from the command line I often (for example on the train) want to put my macbook into a state that will maximise the amount of time I have before the battery runs out - so far example I'll switch off the bluetooth, then switch off the wifi, then alter the brightness - my question is, can I do all of this from the command line? Then I run some nice little script...
You can, but you will need some extra utilities:

brightness - you can download the program at                 http://dev.sabi.net/svn/dev/trunk/LocationDo/brightness.c and compile it using the command:

gcc -std=c99 -o brightness brightness.c -framework IOKit -framework ApplicationServices

Or you can just download it from my server at http://attic.luo.ma/brightness.bz2

Once you have it, brightness 0.01 will lower the brightness as much as possible

Bluetooth - The command you want is blueutil which you can find here https://github.com/toy/blueutil. I have a compiled version of that available at http://attic.luo.ma/blueutil2.bz2. I also have another, older version of a program by the same name which you can download from http://attic.luo.ma/blueutil.bz2.

Whichever program you use, the -h flag will explain how to use it.

Wi-Fi - You can turn AirPort power on or off using:

networksetup -setairportpower &lt;device name&gt; &lt;on off&gt;

where &lt;device name&gt; is probably either en0 or en1

You can find out which it is using 

networksetup -listnetworkserviceorder | egrep "Wi-Fi, Device"

For my MacBook Air (which uses en0), the command to turn it off is:

networksetup -setairportpower en0 off

More Settings

Be sure that you have changed the Energy Settings in System Preferences too, but you can also set them using:

sudo pmset -b sleep 10

to tell the computer to sleep after 10 minutes when on battery, and/or:

sudo pmset -b displaysleep 5

to tell the computer display to sleep after 5 minutes, when on battery (the -b flag indicates battery).

pmset -g

will show you your current settings.