Displays the current Git branch and modification statistics in the statusline.
- Shows current Git branch
- Displays number of modified files
- Shows line additions/deletions
- Separate colors for branch and stats
- Automatically hides when not in a Git repository
{
"name": "git",
"prefix": "",
"color": "green",
"options": {
"showFileCount": true,
"showLineStats": true,
"dirtyColor": "yellow"
}
}-
icon(string): Prefix to display before the branch name- Default:
""(Git branch icon) - Example:
"","±",""
- Default:
-
color(string): Color for the branch name (when clean or with changes)- Default:
"green" - Available:
"blue","cyan","green","yellow","magenta","red","gray"
- Default:
-
showFileCount(boolean): Show number of modified files- Default:
true - Format:
!3(3 modified files)
- Default:
-
showLineStats(boolean): Show line additions and deletions- Default:
true - Format:
+45/-12(45 lines added, 12 deleted)
- Default:
-
dirtyColor(string): Color for the modification stats (file count + line stats)- Default:
"yellow" - Only applies to the
!N +X/-Ypart, not the branch name
- Default:
main
main !3 +45/-12
Where:
main= branch name (incolor)!3= 3 modified files (indirtyColor, hardcoded "!")+45/-12= 45 lines added, 12 deleted (indirtyColor)
{
"plugins": [
{
"name": "git"
}
]
}Output: main !3 +45/-12 (branch in green, stats in yellow)
{
"plugins": [
{
"name": "git",
"options": {
"showFileCount": true,
"showLineStats": false
}
}
]
}Output: main !3
{
"plugins": [
{
"name": "git",
"options": {
"showFileCount": false,
"showLineStats": true
}
}
]
}Output: main +45/-12
{
"plugins": [
{
"name": "git",
"color": "cyan",
"options": {
"dirtyColor": "red"
}
}
]
}Output: main !3 +45/-12 (branch in cyan, stats in red)
{
"plugins": [
{
"name": "git",
"options": {
"showFileCount": false,
"showLineStats": false
}
}
]
}Output: main
{
"plugins": [
{
"name": "git",
"prefix": ""
}
]
}Output: main !3 +45/-12
-
Branch detection:
git rev-parse --abbrev-ref HEAD- Returns current branch name
- Fails silently if not in a Git repo
-
File count:
git status --porcelain- Counts modified, added, deleted files
- Includes staged and unstaged changes
-
Line stats:
git diff --numstat- Shows lines added/deleted per file
- Sums up all changes
- Not in Git repo: Returns empty content (plugin hidden)
- Clean repo: Shows only branch name
- Modified files: Shows branch + stats based on options
- Error handling: Returns empty content on any Git command failure
- Uses
stdio: ['pipe', 'pipe', 'ignore']to suppress stderr - Commands are synchronous but fast (< 50ms typically)
- Errors are ignored silently (no console spam)
# Clean repository
main
# With modifications
main !2 +15/-3
# Many changes
feature-branch !12 +234/-89
# Staging area changes
develop !5 +120/-45- The
!before the file count is hardcoded (not configurable) - Stats only appear if there are actual changes
- Branch name always uses
color, stats always usedirtyColor - If
showFileCountis false, line stats won't show either (file count is required)