Uploading termcap/terminfo for current $TERM to remote server

Termcap:

infocmp | ssh hostname 'dd of=term.terminfo; tic -C term.terminfo | sed "\$s/$/AF=\\\\E[3%dm:AB=\\\\E[4%dm:/" >> .termcap; rm -f term.terminfo'

Terminfo:

infocmp | ssh hostname 'dd of=term.terminfo; tic -o .terminfo/ term.terminfo; rm -f term.terminfo'