This repository contains a custom script that provides a more reliable and full-featured Git status bar component for iTerm2. The original "git state" menu bar component would sometimes not work or not show at all. To address this issue, as well as expand upon the original, this custom script was made. This custom script displays various Git information in the iTerm2 status bar, giving users a quick overview of their repository's state.
The script includes information like:
- Git user name and email
- Current branch
- Number of commits ahead and behind the remote branch
- Number of staged commits
- Number of staged commits on the remote repo
- Number of files that differ between the local and remote branch
- Presence of uncommitted changes
- Presence of and Number of untracked files
Additionally, the script allows you to toggle the display of individual features.
-
Copy the contents of the
bashrc_snippet.sh
file from this repository. -
Open your
~/.bashrc
file using your preferred text editor (e.g.,nano ~/.bashrc
). -
Paste the copied contents at the end of your
~/.bashrc
file and save the changes. -
Restart your terminal or run
source ~/.bashrc
to reload the configuration.
-
Open iTerm2 and go to Preferences (Cmd + ,).
-
Navigate to the "Profiles" tab.
-
Select the profile you are using (usually "Default").
-
Click on the "Session" subtab.
-
Check the "Status bar enabled" checkbox.
-
Click on the "Configure Status Bar" button.
-
Click on the "+" button to add a new component.
-
Choose "Interpolated String" from the list.
-
In the "String Value" field of the newly added component, enter the following text:
\(user.gitInfo)
- Close the Preferences window.
The Git information should now be displayed in the iTerm2 status bar.
You can toggle the display of individual features by setting the corresponding configuration variable to true
or false
in the ~/.bashrc
file. For example, to disable the display of the Git user name and email, set the GIT_SHOW_USER_INFO
variable to false
:
GIT_SHOW_USER_INFO=false
Save the ~/.bashrc
file and restart your shell or run source ~/.bashrc
to reload the changes. The updated Git information will be displayed in the iTerm2 status bar.
A: Make sure you have followed the installation and setup instructions correctly. If the issue persists, try restarting iTerm2.
A: The current script is written for Bash. You may need to modify the script for compatibility with other shells.
A: Feel free to open an issue or submit a pull request if you have any suggestions, improvements, or fixes for this script.
This project is licensed under the MIT License. See the LICENSE file for details.