Skip to content

Instantly share code, notes, and snippets.

@cosmo0920
Last active December 14, 2015 03:09
Show Gist options
  • Save cosmo0920/5018562 to your computer and use it in GitHub Desktop.
Save cosmo0920/5018562 to your computer and use it in GitHub Desktop.
PROMPT vcs_info
autoload -Uz vcs_info
zstyle ':vcs_info:*' formats '(%s)-[%b]'
zstyle ':vcs_info:*' actionformats '(%s)-[%b|%a]'
precmd () {
psvar=()
LANG=en_US.UTF-8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
}
autoload -Uz is-at-least
if is-at-least 4.3.10; then
# zshが4.3.10以上の場合にcheck-for-changesを有効にする
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' stagedstr "+"
zstyle ':vcs_info:git:*' unstagedstr "-"
zstyle ':vcs_info:git:*' formats '(%s)[%b]%u%c'
zstyle ':vcs_info:git:*' actionformats '%s,%u%c,%b|%a'
fi
# プロンプトを表示直前に呼び出される組み込みのprecmd()関数をフックする関数
function _precmd_vcs_info() {
psvar=()
LANG=en_US.UTF-8 vcs_info
psvar[1]=$vcs_info_msg_0_
}
add-zsh-hook precmd _precmd_vcs_info
RPROMPT="%1(v|%F{blue}%1v%f|)"
# プロンプト定義
local LEFTC=$'%F{cyan}'
#local RIGHTC=$'%{\e[38;5;88m%}'
local DEFAULTC=$'%f'
RPROMPT+="%(?.%F{green}[OK]%f.%F{red}[Fail]%f)"
#SPROMPT="%r is correct? [n,y,a,e]: "
PROMPT="$LEFTC%n@%m$DEFAULTC %c%% "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment