diff --git a/roles/zsh/files/config/configs/prompt.zsh b/roles/zsh/files/config/configs/prompt.zsh index 3ac57cf5..46e359e7 100644 --- a/roles/zsh/files/config/configs/prompt.zsh +++ b/roles/zsh/files/config/configs/prompt.zsh @@ -1,15 +1,15 @@ -source $ZDOTDIR/oh-my-zsh/git.zsh +setopt prompt_subst -git_prompt_prefix() { - local tag="$(git describe --tags 2> /dev/null)" +git_branch() { + local branch="$(git symbolic-ref HEAD 2> /dev/null | cut -d'/' -f3)" - [ -n "${tag}" ] && echo "%{$fg[yellow]%}${tag}%{$reset_color%} " + [ -n "${branch}" ] && echo " (${branch})" } -git_prompt_suffix() { - local branch="$(git_current_branch)" +git_commit() { + local commit_sha="$(git rev-parse --short HEAD 2> /dev/null)" - [ -n "${branch}" ] && echo " on %{$fg[green]%}${branch}%{$reset_color%}" + [ -n "${commit_sha}" ] && echo " [${commit_sha}]" } -export PS1="$(git_prompt_prefix)in %{$fg[blue]%}%1d/%{$reset_color%}$(git_prompt_suffix) " +export PS1='%{$fg[blue]%}%1d%{$reset_color%}%{$fg[green]%}$(git_branch)%{$reset_color%}%{$fg[yellow]%}$(git_commit)%{$reset_color%} $ '