Skip to content

Instantly share code, notes, and snippets.

@wilmoore
Created October 11, 2012 18:59
Show Gist options
  • Save wilmoore/3874729 to your computer and use it in GitHub Desktop.
Save wilmoore/3874729 to your computer and use it in GitHub Desktop.
Terminal Tab reflecting your current git project name

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:

1

Your terminal tab when you are not in a configured project:

2

@wilmoore
Copy link
Author

I now use tmux heavily so this is even easier. I have the following in my ~/.tmux.conf:

set -g set-titles-string '#(tmux display-message -p "#S")'

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment