Skip to content

Mostly just generalizing customization. #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

dir = $(HOME)/.zsh/git-prompt
src += gitstatus.py
src += zshrc.sh
dst = $(addprefix $(dir)/, $(src))

.PHONY: install

install: $(dir) $(dst)

$(dir):
mkdir -vp $(dir)

$(dir)/%: %
sudo install -m 0444 $< $@

12 changes: 12 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,16 @@ Install
#. You may also redefine the function ``git_super_status`` (after the ``source`` statement) to adapt it to your needs (to change the order in which the information is displayed). Define the variable ``ZSH_THEME_GIT_PROMPT_NOCACHE`` in order to disable caching. You may also change a number of variables (which name start with ``ZSH_THEME_GIT_PROMPT_``) to change the appearance of the prompt. Take a look in the file ``zshrc.sh`` to see how the function ``git_super_status`` is defined, and what variables are available.
#. Go in a git repository and test it!

Customization
-------------

The following parameters may be set prior to sourcing ``zshrc.sh``.

* ``GIT_PROMPT_DIR`` -- directory in which to find ``gitstatus.py``
* ``ZSH_THEME_GIT_PROMPT_BRANCH_COLOR`` -- prompt color for branch
* ``ZSH_THEME_GIT_PROMPT_STAGED_COLOR`` -- prompt color for staged
* ``ZSH_THEME_GIT_PROMPT_CONFLICTS_COLOR`` -- prompt color for conflicts
* ``ZSH_THEME_GIT_PROMPT_CHANGED_COLOR`` -- prompt color for changed
* ``ZSH_THEME_GIT_PROMPT_CLEAN_COLOR`` -- prompt color for clean

**Enjoy!**
37 changes: 28 additions & 9 deletions zshrc.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# To install source this file from your .zshrc file

if ! which python > /dev/null
then
# If we don't have python, then create a stub and return.
git_super_status() { }
return
fi

# Change this to reflect your installation directory
export __GIT_PROMPT_DIR=~/.zsh/git-prompt
# Initialize colors.
autoload -U colors
colors
: ${GIT_PROMPT_DIR:=$HOME/.zsh/git-prompt}
export __GIT_PROMPT_DIR=$GIT_PROMPT_DIR

# Commonly, colors is already loaded.
if [[ -z $color ]]
then
# Initialize colors.
autoload -U colors
colors
fi

# Allow for functions in the prompt.
setopt PROMPT_SUBST
Expand Down Expand Up @@ -80,16 +93,22 @@ git_super_status() {
fi
}

: ${ZSH_THEME_GIT_PROMPT_BRANCH_COLOR:=$fg_bold[magenta]}
: ${ZSH_THEME_GIT_PROMPT_STAGED_COLOR:=$fg[red]}
: ${ZSH_THEME_GIT_PROMPT_CONFLICTS_COLOR:=$fg[red]}
: ${ZSH_THEME_GIT_PROMPT_CHANGED_COLOR:=$fg[red]}
: ${ZSH_THEME_GIT_PROMPT_CLEAN_COLOR:=$fg_bold[green]}

# Default values for the appearance of the prompt. Configure at will.
ZSH_THEME_GIT_PROMPT_PREFIX="("
ZSH_THEME_GIT_PROMPT_SUFFIX=")"
ZSH_THEME_GIT_PROMPT_SEPARATOR="|"
ZSH_THEME_GIT_PROMPT_BRANCH="%{$fg_bold[magenta]%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg[red]%}●"
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$fg[red]%}✖"
ZSH_THEME_GIT_PROMPT_CHANGED="%{$fg[blue]%}✚"
ZSH_THEME_GIT_PROMPT_BRANCH="%{$ZSH_THEME_GIT_PROMPT_BRANCH_COLOR%}"
ZSH_THEME_GIT_PROMPT_STAGED="%{$ZSH_THEME_GIT_PROMPT_STAGED_COLOR%}●"
ZSH_THEME_GIT_PROMPT_CONFLICTS="%{$ZSH_THEME_GIT_PROMPT_CONFLICTS_COLOR%}✖"
ZSH_THEME_GIT_PROMPT_CHANGED="%{$ZSH_THEME_GIT_PROMPT_CHANGED_COLOR%}✚"
ZSH_THEME_GIT_PROMPT_REMOTE=""
ZSH_THEME_GIT_PROMPT_UNTRACKED="…"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[green]%}✔"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$ZSH_THEME_GIT_PROMPT_CLEAN_COLOR%}✔"