dotfiles/roles/zsh/files/config/configs/prompt.zsh

16 lines
426 B
Bash
Raw Normal View History

setopt prompt_subst
2022-05-23 11:26:36 +00:00
git_branch() {
local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)"
2022-05-23 11:26:36 +00:00
[ -n "${branch}" ] && echo " (${branch})"
2022-05-27 17:31:52 +00:00
}
git_commit() {
local commit_sha="$(git rev-parse --short HEAD 2> /dev/null)"
2022-05-23 11:26:36 +00:00
[ -n "${commit_sha}" ] && echo " [${commit_sha}]"
2022-05-23 11:26:36 +00:00
}
2022-05-27 17:31:52 +00:00
export PS1='%{$fg[blue]%}%1d%{$reset_color%}%{$fg[green]%}$(git_branch)%{$reset_color%}%{$fg[yellow]%}$(git_commit)%{$reset_color%} $ '