Skip to content

Commit

Permalink
Add giddie theme
Browse files Browse the repository at this point in the history
  • Loading branch information
sorin-ionescu committed Aug 18, 2013
1 parent 773ca7e commit 8e947d3
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions modules/prompt/functions/prompt_giddie_setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#
# A colorful, friendly, multiline theme with some handy features.
#
# Authors:
# Paul Gideon Dann <[email protected]>
# Sorin Ionescu <[email protected]>
#
# Features:
# - Simple VCS branch, staged and unstaged indication.
# - Prompt character is different in a VCS repository.
# - Last command exit status is displayed when non-zero.
#
# Screenshots:
# http://i.imgur.com/rCo3S.png
#

function +vi-git-status() {
# Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then

This comment has been minimized.

Copy link
@giddie

giddie Nov 13, 2013

Contributor

I don't think git ls-files --other --exclude-standard shows any changes in submodules (untracked content, modified content, or new commits). It also doesn't show up staged submodules. Or at least I'm not seeing them returned when I run the command... Any ideas?

This comment has been minimized.

Copy link
@sorin-ionescu

sorin-ionescu via email Nov 14, 2013

Author Owner

This comment has been minimized.

Copy link
@giddie

giddie Nov 14, 2013

Contributor

Yes, that much was clear to me. What I mean is that I can see that it correctly indicates the presence of untracked files, but it doesn't seem to indicate anything about submodules. How is it supposed to indicate "updated submodules", as per the comment?

This comment has been minimized.

Copy link
@sorin-ionescu

sorin-ionescu via email Nov 14, 2013

Author Owner

This comment has been minimized.

Copy link
@giddie

giddie Nov 15, 2013

Contributor

Yes, when you navigate inside a submodule, the prompt naturally reflects the fact that we've moved into a different repository. In that situation, as in the parent repository, the git ls-files ... line correctly determines whether or not there are untracked files in the current repository (which happens to be a submodule).

hook_com[unstaged]='%F{green}!%f'
fi
}

function prompt_giddie_precmd {
# Replace '/home/<user>' with '~'.
_prompt_giddie_pwd="${PWD/#$HOME/~}"

# Choose prompt symbol based on whether or not we are in a repository.
if (( $+commands[git] )) && git rev-parse 2> /dev/null; then
_prompt_giddie_symbol='±'
vcs_info
else
_prompt_giddie_symbol=')'
fi
}

function prompt_giddie_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)

# Load required functions.
autoload -Uz vcs_info
autoload -Uz add-zsh-hook

# Add hook to set up prompt parameters before each command.
add-zsh-hook precmd prompt_giddie_precmd

# Set editor-info parameters.
zstyle ':prezto:module:editor:info:completing' format '%F{green}...%f'

# Set vcs_info parameters.
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' formats ' on %F{magenta}%b%f%c%u'
zstyle ':vcs_info:*' actionformats ' on %F{magenta}%b%f%c%u %F{yellow}(%a)%f'
zstyle ':vcs_info:*' stagedstr '%F{green}+%f'
zstyle ':vcs_info:*' unstagedstr '%F{green}!%f'
zstyle ':vcs_info:git*+set-message:*' hooks git-status

# Define prompts.
PROMPT='%(?..%F{red}%B-> [%?]%b%f
)%F{magenta}%n%f@%F{yellow}%m%f|%F{green}${_prompt_giddie_pwd}%f${vcs_info_msg_0_}
%F{blue}${_prompt_giddie_symbol}%f '
RPROMPT=''
SPROMPT='zsh: correct %F{magenta}%R%f to %F{green}%r%f [nyae]? '
}

prompt_giddie_setup "$@"

0 comments on commit 8e947d3

Please sign in to comment.