diff --git a/modules/git/README.md b/modules/git/README.md index eaac944..b1db63a 100644 --- a/modules/git/README.md +++ b/modules/git/README.md @@ -208,7 +208,6 @@ You can temporarily bypass an alias by prefixing it with a backward slash: Functions --------- - General: - `git-branch-current` displays the current branch. - `git-commit-lost` lists lost commits. - `git-dir` displays the path to the Git directory. @@ -221,7 +220,3 @@ Functions - `git-stash-recover` recovers given dropped stashed states. - `git-submodule-move` moves a submodule. - `git-submodule-remove` removes a submodule. - - Prompt: - - `git_prompt_info` provides git information to oh-my-zsh sourced prompts. - - `parse-git-dirty` needed for `git-prompt-info` to check if repo is dirty. diff --git a/modules/git/functions/git_prompt_info b/modules/git/functions/git_prompt_info deleted file mode 100644 index 269d0db..0000000 --- a/modules/git/functions/git_prompt_info +++ /dev/null @@ -1,8 +0,0 @@ -# slightly modified git_prompt_info from oh-my-zsh for theme compatibility - -local ref -if [[ ${zgit_hide_prompt} != 'true' ]]; then - ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ - ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 - print "${ZSH_THEME_GIT_PROMPT_PREFIX}${ref#refs/heads/}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" -fi diff --git a/modules/git/functions/parse_git_dirty b/modules/git/functions/parse_git_dirty deleted file mode 100644 index 1b8be78..0000000 --- a/modules/git/functions/parse_git_dirty +++ /dev/null @@ -1,17 +0,0 @@ -# slightly modified parse_git_dirty from oh-my-zsh for theme compatibility -# not supporting git < 1.7.2; upgrade your shit - -local STATUS='' -local FLAGS -FLAGS=('--porcelain' '--ignore-submodules=dirty') -if [[ ${zgit_hide_prompt} != 'true' ]]; then - if [[ "${zgit_disable_untracked_dirty}" == "true" ]]; then - FLAGS+='--untracked-files=no' - fi - STATUS=$(command git status ${FLAGS} 2> /dev/null | tail -n1) -fi -if [[ -n ${STATUS} ]]; then - print ${ZSH_THEME_GIT_PROMPT_DIRTY} -else - print ${ZSH_THEME_GIT_PROMPT_CLEAN} -fi diff --git a/modules/prompt/themes/gitster.zsh-theme b/modules/prompt/themes/gitster.zsh-theme index 9a3bc32..e7eacb7 100644 --- a/modules/prompt/themes/gitster.zsh-theme +++ b/modules/prompt/themes/gitster.zsh-theme @@ -3,31 +3,37 @@ # https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme # -gst_get_status() { - print "%(?:%F{10}➜ :%F{9}➜ %s)" +prompt_gitster_get_status() { + print '%(?:%F{green}➜:%F{red}➜) ' } -gst_get_pwd() { - prompt_short_dir="$(short_pwd)" - git_root="$(command git rev-parse --show-toplevel 2> /dev/null)" && \ - prompt_short_dir="${prompt_short_dir#${$(short_pwd $git_root):h}/}" +prompt_gitster_get_pwd() { + prompt_short_dir=$(short_pwd) + git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/} print ${prompt_short_dir} } prompt_gitster_precmd() { - PROMPT='$(gst_get_status) %F{white}$(gst_get_pwd) $(git_prompt_info)%f ' + [[ ${+functions[git-info]} ]] && git-info } prompt_gitster_setup() { - ZSH_THEME_GIT_PROMPT_PREFIX="%F{cyan}" - ZSH_THEME_GIT_PROMPT_SUFFIX="%f" - ZSH_THEME_GIT_PROMPT_DIRTY=" %F{yellow}✗%f" - ZSH_THEME_GIT_PROMPT_CLEAN=" %F{green}✓%f" - + autoload -Uz colors && colors autoload -Uz add-zsh-hook + prompt_opts=(cr percent subst) + add-zsh-hook precmd prompt_gitster_precmd - prompt_opts=(cr subst percent) + + zstyle ':zim:git-info:branch' format '%b' + zstyle ':zim:git-info:commit' format '%c' + zstyle ':zim:git-info:clean' format '%F{green}✓' + zstyle ':zim:git-info:dirty' format '%F{yellow}✗' + zstyle ':zim:git-info:keys' format \ + 'prompt' ' %F{cyan}%b%c %C%D' + + PROMPT='$(prompt_gitster_get_status)%F{white}$(prompt_gitster_get_pwd)${(e)git_info[prompt]}%f ' + RPROMPT='' } prompt_gitster_setup "$@"