Skip to content

Commit

Permalink
Consolidated all function files into zshrc.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
axelson committed Aug 2, 2010
1 parent c32259c commit a99dc55
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
1 change: 0 additions & 1 deletion functions/chpwd_update_git_vars

This file was deleted.

5 changes: 0 additions & 5 deletions functions/precmd_update_git_vars

This file was deleted.

6 changes: 0 additions & 6 deletions functions/preexec_update_git_vars

This file was deleted.

3 changes: 0 additions & 3 deletions functions/prompt_git_info

This file was deleted.

5 changes: 0 additions & 5 deletions functions/update_current_git_vars.sh

This file was deleted.

45 changes: 36 additions & 9 deletions zshrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,49 @@ colors
# Allow for functions in the prompt.
setopt PROMPT_SUBST

# Autoload zsh functions.
fpath=($__GIT_PROMPT_DIR/functions $fpath)
autoload -U $__GIT_PROMPT_DIR/functions/*(:t)
## 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_git_vars'
precmd_functions+='precmd_update_git_vars'
chpwd_functions+='chpwd_update_git_vars'

## Function definitions
function preexec_update_git_vars() {
case "$2" in
git*)
__EXECUTED_GIT_COMMAND=1
;;
esac
}

function preexec() {
preexec_update_git_vars $@
function precmd_update_git_vars() {
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
update_current_git_vars
unset __EXECUTED_GIT_COMMAND
fi
}

function precmd() {
precmd_update_git_vars $@
function chpwd_update_git_vars() {
update_current_git_vars
}

function chpwd() {
chpwd_update_git_vars $@
function update_current_git_vars() {
unset __CURRENT_GIT_STATUS

local gitstatus="$__GIT_PROMPT_DIR/gitstatus.py"
_GIT_STATUS=`python ${gitstatus}`
__CURRENT_GIT_STATUS=("${(f)_GIT_STATUS}")
}

function prompt_git_info() {
if [ -n "$__CURRENT_GIT_STATUS" ]; then
echo "(%{${fg[red]}%}$__CURRENT_GIT_STATUS[1]%{${fg[default]}%}$__CURRENT_GIT_STATUS[2]%{${fg[magenta]}%}$__CURRENT_GIT_STATUS[3]%{${fg[default]}%})"
fi
}

# Set the prompt.
PROMPT='%B%m%~%b$(prompt_git_info) %# '
Expand Down

0 comments on commit a99dc55

Please sign in to comment.