FYI,
If you wants to set the terminal title as /code/cpp in my above question, do this :
alias precmd 'echo -n "\033]0;`pwd | rev | cut -d/ -f1,2 | rev`\a"'
if you change the filed from -f1,2
to -f1,3
then you can set the title as shibin/code/cpp and so on...