configs/home/.zsh/themes/spaceship-prompt/sections/git_branch.zsh

35 lines
1.2 KiB
Bash
Raw Permalink Normal View History

2022-12-01 13:28:20 +01:00
#
# Git branch
#
# Show current git branch
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
SPACESHIP_GIT_BRANCH_SHOW="${SPACESHIP_GIT_BRANCH_SHOW=true}"
SPACESHIP_GIT_BRANCH_ASYNC="${SPACESHIP_GIT_BRANCH_ASYNC=false}"
SPACESHIP_GIT_BRANCH_PREFIX="${SPACESHIP_GIT_BRANCH_PREFIX="$SPACESHIP_GIT_SYMBOL"}"
SPACESHIP_GIT_BRANCH_SUFFIX="${SPACESHIP_GIT_BRANCH_SUFFIX=""}"
SPACESHIP_GIT_BRANCH_COLOR="${SPACESHIP_GIT_BRANCH_COLOR="magenta"}"
# ------------------------------------------------------------------------------
# Section
# ------------------------------------------------------------------------------
spaceship_git_branch() {
[[ $SPACESHIP_GIT_BRANCH_SHOW == false ]] && return
vcs_info
local git_current_branch="$vcs_info_msg_0_"
[[ -z "$git_current_branch" ]] && return
git_current_branch="${git_current_branch#heads/}"
git_current_branch="${git_current_branch/.../}"
spaceship::section \
--color "$SPACESHIP_GIT_BRANCH_COLOR" \
"$SPACESHIP_GIT_BRANCH_PREFIX$git_current_branch$SPACESHIP_GIT_BRANCH_SUFFIX"
}