Created
July 13, 2016 21:30
-
-
Save devrchancay/afe0e876dddc976e07cbe9eaddc190fa to your computer and use it in GitHub Desktop.
Theme configuration zsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| CURRENT_BG='NONE' | |
| () { | |
| local LC_ALL="" LC_CTYPE="en_US.UTF-8" | |
| SEGMENT_SEPARATOR=$'\ue0b0' | |
| } | |
| prompt_segment() { | |
| local bg fg | |
| [[ -n $1 ]] && bg="%K{$1}" || bg="%k" | |
| [[ -n $2 ]] && fg="%F{$2}" || fg="%f" | |
| if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then | |
| echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} " | |
| else | |
| echo -n "%{$bg%}%{$fg%} " | |
| fi | |
| CURRENT_BG=$1 | |
| [[ -n $3 ]] && echo -n $3 | |
| } | |
| prompt_end() { | |
| if [[ -n $CURRENT_BG ]]; then | |
| echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR" | |
| else | |
| echo -n "%{%k%}" | |
| fi | |
| echo -n "%{%f%}" | |
| CURRENT_BG='' | |
| } | |
| prompt_context() { | |
| if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then | |
| prompt_segment black default "%(!.%{%F{yellow}%}.) $(git log master..$(git rev-parse --abbrev-ref HEAD) --pretty=oneline | wc -l)" | |
| else | |
| prompt_segment black default "%(!.%{%F{yellow}%}.)%{%F{cyan}%}●" | |
| fi | |
| } | |
| prompt_git() { | |
| 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 yellow black | |
| else | |
| prompt_segment green black | |
| fi | |
| if [[ -e "${repo_path}/BISECT_LOG" ]]; then | |
| mode=" <B>" | |
| 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_hg() { | |
| local rev status | |
| if $(hg id >/dev/null 2>&1); then | |
| if $(hg prompt >/dev/null 2>&1); then | |
| if [[ $(hg prompt "{status|unknown}") = "?" ]]; then | |
| prompt_segment red white | |
| st='±' | |
| elif [[ -n $(hg prompt "{status|modified}") ]]; then | |
| prompt_segment yellow black | |
| st='±' | |
| else | |
| prompt_segment green black | |
| fi | |
| echo -n $(hg prompt "☿ {rev}@{branch}") $st | |
| else | |
| st="" | |
| rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') | |
| branch=$(hg id -b 2>/dev/null) | |
| if `hg st | grep -q "^\?"`; then | |
| prompt_segment red black | |
| st='±' | |
| elif `hg st | grep -q "^[MA]"`; then | |
| prompt_segment yellow black | |
| st='±' | |
| else | |
| prompt_segment green black | |
| fi | |
| echo -n "☿ $rev@$branch" $st | |
| fi | |
| fi | |
| } | |
| prompt_dir() { | |
| prompt_segment blue black '%~' | |
| } | |
| prompt_virtualenv() { | |
| local virtualenv_path="$VIRTUAL_ENV" | |
| if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then | |
| prompt_segment blue black "(`basename $virtualenv_path`)" | |
| fi | |
| } | |
| prompt_status() { | |
| local symbols | |
| symbols=() | |
| [[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘" | |
| [[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡" | |
| [[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙" | |
| [[ -n "$symbols" ]] && prompt_segment black default "$symbols" | |
| } | |
| build_prompt() { | |
| RETVAL=$? | |
| prompt_status | |
| prompt_virtualenv | |
| prompt_context | |
| prompt_dir | |
| prompt_git | |
| prompt_hg | |
| prompt_end | |
| } | |
| PROMPT='%{%f%b%k%}$(build_prompt) ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment