irongit

a bin full of cool programs

hygobin/bin/git_branch_str
11 lines285 B
1#!/bin/bash
2branchname=$(git branch --show-current 2>/dev/null)
3if [[ $? -ne 0 ]]; then
4 exit 1
5fi
6if [[ -n $branchname ]]; then
7 echo -e "(\e[3;32m$branchname\e[0m)"
8else
9 branchname=$(git branch | grep -oP '(?<=\().*(?=\))')
10 echo -e "(\e[3;38;5;196m$branchname\e[0m)"
11fi