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-13 00:03:34 +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-13 00:03:34 +01:00
|
|
|
[ -n "${commit_sha}" ] && echo " [%{$fg[yellow]%}${commit_sha}%{$reset_color%}]"
|
2022-05-23 12:26:36 +01:00
|
|
|
}
|
2022-05-27 18:31:52 +01:00
|
|
|
|
2022-07-13 00:03:34 +01:00
|
|
|
export PS1='%{$fg[blue]%}%~%{$reset_color%}%{$fg[green]%}$(git_branch)%{$reset_color%}$(git_commit) $ '
|