iTerm2 title confusion

When working on multiple projects at the same time. I often have the problem that I have multiple windows of iTerm or multiple tabs in a window. They all happen to get the same name by default and I couldn't find any setting to get the folder name as the window title.

I found a little solution for this!

    if [ $ITERM_SESSION_ID ]; then
  export PROMPT_COMMAND='echo -ne "\033];${PWD##*/}\007"; ':"$PROMPT_COMMAND";
fi

Add this to  you bash_profile and reopen your iTerm. Windows will have a better title now.