Created
April 20, 2015 13:50
-
-
Save sio2boss/f480b310b233bd639d69 to your computer and use it in GitHub Desktop.
Oh-My-Zsh Av plugin
This file contains 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
# AV Plugin from: | |
# | |
export __AV_PROMPT_DIR=$ZSH/plugins/av | |
# Allow for functions in the prompt. | |
setopt PROMPT_SUBST | |
## Enable auto-execution of functions. | |
typeset -ga preexec_functions | |
typeset -ga precmd_functions | |
typeset -ga chpwd_functions | |
# Append git functions needed for prompt. | |
preexec_functions+='preexec_update_av_vars' | |
precmd_functions+='precmd_update_av_vars' | |
chpwd_functions+='chpwd_update_av_vars' | |
## Function definitions | |
function preexec_update_av_vars() { | |
case "$2" in | |
git*) | |
__EXECUTED_AV_COMMAND=1 | |
;; | |
esac | |
} | |
function precmd_update_av_vars() { | |
if [ -n "$__EXECUTED_AV_COMMAND" ]; then | |
update_current_av_vars | |
unset __EXECUTED_AV_COMMAND | |
fi | |
} | |
function chpwd_update_av_vars() { | |
update_current_av_vars | |
} | |
function update_current_av_vars() { | |
unset __CURRENT_AV_STATUS | |
_AV_STATUS=`av status` | |
if [ ! -z ${_AV_STATUS} ]; then | |
__CURRENT_AV_STATUS="av" | |
fi | |
} | |
function prompt_av_info() { | |
if [ ! -z "$__CURRENT_AV_STATUS" ]; then | |
echo "%{${fg[green]}%}$__CURRENT_AV_STATUS%{${fg[default]}%}" | |
fi | |
} | |
# Set the prompt. | |
RPROMPT='$(prompt_av_info)' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment