https://github.com/j4ckofalltrades/git-branch-win-title
Add the current git branch to the terminal window title
https://github.com/j4ckofalltrades/git-branch-win-title
bash git shell tmux zsh
Last synced: 5 months ago
JSON representation
Add the current git branch to the terminal window title
- Host: GitHub
- URL: https://github.com/j4ckofalltrades/git-branch-win-title
- Owner: j4ckofalltrades
- Created: 2020-11-22T10:26:21.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-05T16:02:10.000Z (over 2 years ago)
- Last Synced: 2025-10-10T06:27:25.311Z (9 months ago)
- Topics: bash, git, shell, tmux, zsh
- Language: Shell
- Homepage:
- Size: 56.6 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

A small shell function that adds the current git branch (if present) to the terminal emulator window title.
## Requirements
- [Git](https://git-scm.com) v2.2 or higher
- Any [supported terminal emulator](#terminal-emulator-support)
- Any [supported shell interpreter](#shell-interpreter-support)
## Quick Start
Configuration may vary depending on the user's OS, terminal emulator, and shell
interpreter. But in most cases, the following command should be enough:
```sh
$ source branch-win-title.sh
```
You may also want to add this line to your shell configuration file e.g.
`.profile`, `.bashrc`, `.zshrc`, etc.
## Shell interpreter support
- [bash](https://www.gnu.org/software/bash)
- [zsh](https://github.com/zsh-users/zsh)
## Terminal Emulator support
Tested on the following terminal emulators:
- [Alacritty](https://github.com/alacritty/alacritty)
- [iTerm2](https://github.com/gnachman/iTerm2)
- [Gnome Terminal](https://github.com/GNOME/gnome-terminal)
- [Guake](https://github.com/Guake/guake)
## Additional configuration
### Powerline
The `branch-win-title.sh` script must be loaded first before configuring
powerline otherwise it will override the powerline-generated shell prompt.
### Guake
Enable the following settings under `Main Window`:
- Show tab bar
- Use VTE titles for tab names
### iTerm2
Enable the following settings under `Preferences > Profiles`:
- Terminal may set tab/window title
### Tmux
Add the following entries to `.tmux.conf`:
```bash
set-option -g set-titles on
set-option -g set-titles-string "#T"
set-option -g automatic-rename on
```
## Demo
