First, setup a git alias:
% git config --global alias.project-name 'config --replace-all project.info.name'
Use it like this (your CWD should be a git project):
% git project-name "NodeJS Latest"
Review the setting with:
% git config --local --get project.info.name
In your bash profile:
export PROMPT_COMMAND="echo -ne \"\033]0;\$(git config --get project.info.name || $PROMPT_COMMAND)\007\"; $PROMPT_COMMAND"
Your terminal tab when you are within a configured project:
Your terminal tab when you are not in a configured project:
I now use tmux heavily so this is even easier. I have the following in my
~/.tmux.conf
:This puts the name of the session into the terminal tab -- so much easier and does not rely on git (i.e. you may have not yet run
git init
or you may be using another VCS).