I use the preexec function in zsh to do this before hand, see the following:
Code:
function preexec() {
local a=${${1## *}[(w)1]}
local b=${a##*\/}
a="${b}${1#$a}"
a=${a//\%/\%\%}
a=$(print -Pn "$a" | tr -d "\t\n\v\f\r")
a=${(V)a//\%/\%\%}
a=${a:0:14}
case "$TERM" in
screen-256color ) print -Pn "\ek%n@%m:%-3~[$a]\e\\" ;;
esac
}
I use pretty much the same function/config across all of my machines, but you can use a function in your shell's config (zsh, bash, etc) to do this as well. Found the following doing a quick search, it may suffice for what you are looking for -
http://superuser.com/questions/24929...e-ssh-hostname