Skip to content

Commit

Permalink
Merge remote branch 'axelson/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierverdier committed Aug 2, 2010
2 parents faf8702 + a99dc55 commit c56098b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 30 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*~
.*.swp
1 change: 0 additions & 1 deletion chpwd_update_git_vars.sh

This file was deleted.

5 changes: 0 additions & 5 deletions precmd_update_git_vars.sh

This file was deleted.

6 changes: 0 additions & 6 deletions preexec_update_git_vars.sh

This file was deleted.

3 changes: 0 additions & 3 deletions prompt_git_info

This file was deleted.

5 changes: 0 additions & 5 deletions update_current_git_vars.sh

This file was deleted.

54 changes: 44 additions & 10 deletions zshrc.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,59 @@
# To install source this file from your .zshrc file

# Change this to reflect your installation directory
export __GIT_PROMPT_DIR=~/.zsh/git-prompt
# Initialize colors.
autoload -U colors
colors

# Allow for functions in the prompt.
setopt PROMPT_SUBST

# Autoload zsh functions.
fpath=(~/.zsh/functions $fpath)
autoload -U ~/.zsh/functions/*(:t)

# Enable auto-execution of functions.

## 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 precmd_update_git_vars() {
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
update_current_git_vars
unset __EXECUTED_GIT_COMMAND
fi
}

function chpwd_update_git_vars() {
update_current_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) %# '
# for a right prompt:
# RPROMPT='%b$(prompt_git_info)'
# RPROMPT='%b$(prompt_git_info)'

0 comments on commit c56098b

Please sign in to comment.