This repository has been archived on 2025-12-28. You can view files and clone it, but cannot push or open issues or pull requests.
inks-scripts/scripts/bash-status-git
2022-06-04 18:18:13 +09:30

16 lines
380 B
Bash
Executable File

#!/bin/sh
if git status &>/dev/null; then
branch=$(git branch --show-current)
read -ra counts <<< $(git rev-list --left-right --count $branch...origin/$branch)
to_push=${counts[0]}
to_pull=${counts[1]}
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
echo "($branch* $to_push$to_pull↓)"
else
echo "($branch~ $to_push$to_pull↓)"
fi
fi