Using screen for lazy dot files

I have a lot of shell accounts; on my laptops and workstations, on my ARM build boxes, on remote servers, and so on. I don’t make a lot of customisations to my login shell as the lowest common denominator of OS X, FreeBSD and various Linux distros has trained me to live with what is on the host.

I do have two exceptions, bash and screen1. Handling my screen config is easy; just scp my .screenrc file to the new host. Handling the small number of changes to my bash setup is more involved as bash has several places it looks in (.bashrc, .bash_profile, sometimes just .profile) and those files may already exist on the host.

Recently I’ve been experimenting with the idea of using screen to handle this customisation, which reduces the amount of configuration data copied to a new host to a single new file. Here is a sample .screenrc from an ARM FreeBSD build box.

startup_message off
vbell off

# Window list at the bottom.
hardstatus alwayslastline "%{wk}%-w%{Gk}[%n %t]%{wk}%+w%=%{Ck}%M%d %c%{-} %{=r} ${USER}@%H"

# who needs .bashrc ?
shell bash
setenv PS1 "\[\e]0;\u@\h: \w\a\]\h(\w) % "
setenv GOROOT /u/go                           
setenv GOPATH $HOME
# yup, screen can expand shell vars
setenv PATH $PATH:$GOROOT/bin:$GOPATH/bin 

autodetach on
term xterm-color
termcapinfo xterm ti@:te@

Combined with ssh $HOST -t -- screen -R -D, this makes setting up a new machine very simple.


1. Note to haters. I know that alternatives like zsh and tmux exist, but neither are installed by default on any mainstream distro, so until they are, I don’t care. At any rate, these suggestions probably apply equally well to your chosen shell and screen multiplexer.

How to decode travel agent speak

From the useless-trivia-department

My job takes me to strange foreign lands occasionally. As Australia is long way from anywhere, these trips are long and spine breaking. As a consequence, there is a great deal of negotiation with the travel agent to find the best (for relative values of best) flight with the least amount of time wasted in layovers and on a relatively modern aircraft. Along the way I’ve learn how to speak travel agent, a dialect that emerged in Texas in the late 1950’s.

Here is an example

BA  16  Q  17SEP  SYD  LHR   1545  0530+1 E1/744

Properly translated this reads; British Airways flight BA16 from Sydney, Australia to London Heathrow leaving at 3:45pm on the 18th of September and arriving at 5:30 am on the 18th. The aircraft will be a Boeing 747-400 and there is an unnamed stop en route (probably Singapore).

Here is another

EK 413  L  17SEP  SYD  DXB   2110  0540+1 E0/388

It reads; Emirates Airlines flight EK413 leaving Sydney at 9:10PM on the 17th flying direct to Dubai on an Airbus A380.

The +1 in both cases indicate that although it appears you are flying backwards in time, you’ve actually spent a day in the air.

OS X has a built in WiFi scanner

Did you know that OS X has a built in WiFi survey tool? Nope, neither did I, but here it is

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport

This won’t be in your path, so to make things easier you could add the following to your ~/.profile

% alias airport=/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport

Here is an example of the output.

% airport -s
SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group)
fibble 00:26:de:ad:be:ef -59 9 Y -- WEP
flobble 00:60:ca:fe:ba:be -66 6 N AU WPA(PSK/TKIP,AES/TKIP) WPA2(PSK/TKIP,AES/TKIP)
wibble 94:44:51:51:51:51 -62 6,+1 Y -- WPA(PSK/AES,TKIP/TKIP) WPA2(PSK/AES,TKIP/TKIP)
wobble 00:21:af:af:af:af -60 3 N US WPA(PSK/TKIP/TKIP)
ftang 00:18:3b:00:b1:15 -73 11 N -- NONE

For the nitpickers, this data is also available in WIFi icon on the menu, with the important distinction that you can only find out the channel and signal strength if you associate with the AP. Using this tool you can easily do a quick WiFi survey to pick a good channel to avoid side lobe interference (hat tip to Matt Ryall).