Add that to your ~/.bashrc file. The password length can be specified as an argument (defaults to 8).
function mkpw() { head /dev/urandom | uuencode -m - | sed -n 2p | cut -c1-${1:-8}; }
Example usage:
On Ubuntu, the uuencode program is in the sharutils package. Alternatively, you could replace uuencode with md5sum or sha1sum, which would restrict the passwords to hex digits (and which would therefore make them appropriate for WEP keys and the like):
$ mkpw
B5PcCWC3
$ mkpw 10
V8T7ZrTQuN
function mkpw_md5() { head /dev/urandom | md5sum | cut -c1-${1:-8}; }
function mkpw_sha1() { head /dev/urandom | sha1sum | cut -c1-${1:-8}; }