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