diff --git a/themes/logicalhacking.zsh-theme b/themes/logicalhacking.zsh-theme index 15e80bc..37b8627 100755 --- a/themes/logicalhacking.zsh-theme +++ b/themes/logicalhacking.zsh-theme @@ -113,6 +113,50 @@ prompt_isabelle_env() { fi } +# Prompt: git information (branch/detached head, dirty status) +prompt_git() { + (( $+commands[git] )) || return + local PL_BRANCH_CHAR + () { + local LC_ALL="" LC_CTYPE="en_US.UTF-8" + PL_BRANCH_CHAR=$'\ue0a0' #  + } + local ref dirty mode repo_path + repo_path=$(git rev-parse --git-dir 2>/dev/null) + + if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then + dirty=$(parse_git_dirty) + ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)" + if [[ -n $dirty ]]; then + prompt_segment "$1" "$3" + else + prompt_segment "$2" "$3" + fi + + if [[ -e "${repo_path}/BISECT_LOG" ]]; then + mode=" " + elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then + mode=" >M<" + elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then + mode=" >R>" + fi + + setopt promptsubst + autoload -Uz vcs_info + + zstyle ':vcs_info:*' enable git + zstyle ':vcs_info:*' get-revision true + zstyle ':vcs_info:*' check-for-changes true + zstyle ':vcs_info:*' stagedstr '✚' + zstyle ':vcs_info:*' unstagedstr '●' + zstyle ':vcs_info:*' formats ' %u%c' + zstyle ':vcs_info:*' actionformats ' %u%c' + vcs_info + echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}" + fi +} + + # Prompt Setup and key bindings build_prompt() { @@ -120,6 +164,7 @@ build_prompt() { prompt_logo $LHORANGE black prompt_isabelle_env $LHCYAN black prompt_dir $LHLIGHTORANGE black + prompt_git $LHYELLOW $LHGREEN black prompt_end } @@ -128,6 +173,7 @@ build_inactive_prompt() { prompt_logo $LHDARKGRAY white prompt_isabelle_env $LHLIGHTGRAY white prompt_dir $LHLIGHTGRAY white + prompt_git $LHDARKGRAY $LHDARKGRAY white prompt_end } @@ -157,11 +203,16 @@ if [[ "$TERM" =~ ".*256.*" ]]; then LHDARKGRAY="235" LHLIGHTGRAY="008" LHCYAN="014" + LHYELLOW="003" + LHGREEN="002" else LHORANGE="068" LHLIGHTORANGE="016" LHDARKGRAY="019" LHLIGHTGRAY="008" LHCYAN="014" + LHYELLOW="003" + LHGREEN="002" fi +