Konsole tab names by script. Ssh wrapper

I have a lot of small scripts, which are very useful for me, but the famous one by my friends is ssh wrapper for Konsole.
At work I usually have a lot of opened ssh sessions to different servers. My work system is linux notebook and Konsole as default terminal emulator. So some years ago I wrote small ssh wrapper, which set name to Konsole tab by last argument to ssh (hostname).

antony@amaliya:$ cat /usr/local/bin/ssh
#!/bin/bash
# Kocsole wrapper around ssh to rename tabs
# anton@pavlenko.net

REAL_SSH=/usr/bin/ssh
DCOP=/opt/kde/bin/dcop

if [ ! -z "$KONSOLE_DCOP_SESSION" ]
then

 # Use the last argument as the title
 for arg in $@; do
 NEW_TITLE="$arg"
 done

 OLD_TITLE=`dcop "$KONSOLE_DCOP_SESSION" sessionName`
 $DCOP "$KONSOLE_DCOP_SESSION" renameSession "$NEW_TITLE"

 function restore_title() {
 $DCOP "$KONSOLE_DCOP_SESSION" renameSession "$OLD_TITLE"
 }

 # If SSH is interrupted (CTRL-C), restore the old title
 trap "restore_title" SIGINT
 $REAL_SSH $*
 restore_title

else
 $REAL_SSH $*
fi

So if you have the same problems – use this wrapper!