Wow, that's really useful.
For everyone who is as bad as me in bash, to actually use it put it like this in your bashrc:
function clip() { [ -t 0 ] && pbpaste || pbcopy }
function clip() { [ -t 0 ] && pbpaste || pbcopy }
clip() { [ -t 0 ] && pbpaste || pbcopy;}
function clip { [ -t 0 ] && pbpaste || pbcopy;}