I use a little perl script, because it works everywhere I need it (and I suck at shell scripting ;))
> cat `which title`
#!/usr/bin/perl
print(
"\x1b",
"]2;",
join(' ', @ARGV),
"\x7",
);