On OSX you can do something a little less fancy with pbcopy | pbpaste. I normally use it to copy text from files to an email / url output etc.
I added the call to `ansifilter`:
function clip
if not tty >/dev/null
ansifilter | pbcopy
else
pbpaste
end
end