I followed unix s.e post and added the line,
trap 'echo -ne "\033]0;$BASH_COMMAND\007"' DEBUG
to my .bashrc file to set my last command as the terminal title. It works good on my ubuntu desktop machine.
When i add this line to my Centos server's .bashrc file and ssh into the Centos machine, it no longer works. SSH client terminal title has become blank and it prints all junk stuff on my console after every command,
Last login: Sun Jun 7 21:28:29 2015 from sk-box
]2;printf "k%s@%s:%s]0;printf "k%s@%s:%s" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"[root@sk-vbox ~]# cd
]2;printf "k%s@%s:%s]0;printf "k%s@%s:%s" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"[root@sk-vbox ~]# pwd
/root
]2;printf "k%s@%s:%s]0;printf "k%s@%s:%s" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/~}"[root@sk-vbox ~]#
Is it possible to ensure that dynamic title works well over ssh?