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