From 9de97768c59ff9386fd461bdedb7a9d4b0000ccd Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Tue, 17 May 2011 17:10:42 -0700 Subject: [PATCH 01/29] add aliases for editing zsh files and sourcing them --- custom/aliases.zsh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom/aliases.zsh b/custom/aliases.zsh index e77ed8bbb..cd8b0bd26 100644 --- a/custom/aliases.zsh +++ b/custom/aliases.zsh @@ -50,7 +50,8 @@ alias v.='vim .' alias v='vim ~/.vimrc' alias VS='vim -S Session.vim' -alias zs='source ~/.zshrc; source ~/.zshenv' +alias z='vim -o ~/.zshenv ~/.oh-my-zsh/custom/aliases.zsh ~/.zshrc' +alias zs='source ~/.zshrc' if [[ -x "${commands[htop]}" ]]; then From 369670184cb74960e190d0887dd11ff78036787f Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Tue, 17 May 2011 17:11:11 -0700 Subject: [PATCH 02/29] polish ashleydev theme --- themes/ashleydev.zsh-theme | 594 ++++++++++++++++++++++--------------- 1 file changed, 351 insertions(+), 243 deletions(-) diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index 64fcc7f98..008f4e1fb 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -1,9 +1,31 @@ #-------------------- PROMPT definition: ---------------------- # Set the prompt. -# 'R'eset formats +# 'R'eset formating local R="%{$terminfo[sgr0]%}" +# special colors for privileged users (root) +local user_="%(!.%{$fg_bold[yellow]$bg[red]%}.%{$fg_bold[cyan]%})%n$R" +local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m$R" +local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~$R" +local jobs_="%(1j.%{$fg[blue]%}%j$R.)" + +PROMPT='$user_$host_$path_ $(git_prompt_info)$jobs_# ' + +local date_format_="%D{%a %b %d}, %*" +local date_="%{$fg[green]%}[$date_format_]" +local return_code_="%(?..%{$fg[red]%}%? ↵ )" + +RPROMPT='$return_code_$R$date_$R' + +# use the vi-mode oh-my-zsh plugin to get this: +MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" + +#----------------------------------------------------- +# git prompt info: + +local GIT_PROMPT_SHOWUPSTREAM="verbose" + # git_prompt_info colors ('_C' for color): local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo @@ -16,23 +38,122 @@ local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty local _Cp_="%{${fg[cyan]}%}" # upstream info local _Cs_="" # stash state +# will set __GIT_PROMPT_INFO +__git_prompt_format_and_color_with_shortcircuit () +{ + local g="$(__git_dir)" + if [ -z "$g" ]; then + __GIT_PROMPT_INFO='' + return + fi -# special colors for privileged users (root) -local jobs_="%{$fg[blue]%}%(1j.%j.)" -local user_="%(!.%{$fg_bold[yellow]$bg[red]%}.%{$fg_bold[cyan]%})%n" -local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m" -local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~" + local w="" # workspace state + local s="" # stash state + local i="" # index state + local u="" # untracked files state + local p="" # u'p'stream state + local b="$(__git_branch)" # branch + local r="$(__git_rebase_info)" # rebase info -PROMPT='$user_$R$host_$R$path_$R $(git_prompt_info)$R$jobs_$R# ' + if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + if [ "$GIT_PROMPT_SHOWDIRTYSTATE" != 'off' ]; then + if [ "$(git config --bool prompt.showDirtyState)" != "false" ]; then + # This is the short circuit logic: + # The following 3 functions can take a long time on big + # repositories, so check to see if ctrl-c is entered by + # setting _big_repo for the duration of these functions: + # (Then check for _big_repo in TRAPINT().) + _big_repo='yes' + i="$(__git_dirty_state_staged)" + w="$(__git_dirty_state_unstaged)" + u="$(__git_dirty_state_untracked_files)" + _big_repo='' + fi + fi + s="$(__git_stash_state)" + p="$(__git_upstream)" + fi -local date_format_="%D{%a %b %d}, %*" -local date_="%{$fg[green]%}[$date_format_]" -local return_code_="%(?..%{$fg[red]%}%? ↵ )" + if [ -z "$b$i$w$u" ]; then + if [ -n "$g" ]; then + __GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R" + return + fi + fi -# use the vi-mode oh-my-zsh plugin to get this: -MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" + if [ "$s" = 'dirty' ]; then + s="$_Cs_\$$R" + else + s="" + fi -RPROMPT='$return_code_$R$date_$R' + if [ -n "$p" ]; then + p="$_Cp_$p$R" + fi + + if [ "$i" = "dirty" ]; then + i="$_Ci_+$R" + else + i="" + fi + + if [ -n "$b" ]; then + if [ "$w" = "fresh" ]; then + # this is a fresh repo, nothing here... + b="$_Cb_new_repo_$b$R" + elif [ "$w" = 'dirty' ]; then + b="$_Cb_dirty_$b$R" + elif [ "$w" = 'clean' ]; then + b="$_Cb_clean_$b$R" + fi + fi + + if [ -n "$r" ]; then + r="$_Cr_$r$R" + fi + + local _prompt="$b$r$s$i$p" + + # add ( ) around _prompt: + if [ "$u" = "dirty" ]; then + _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" + elif [ "$u" = "clean" ]; then + _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" + else + _prompt="($_prompt)" + fi + + # NOTE: This function must set __GIT_PROMPT_INFO to return it's value, + # rather than echo'ing it for the caller to call it as: + # __GIT_PROMPT_INFO=$(__git_prompt_format_and_color_with_shortcircuit) + # because if we were to call this function in $(...), then the short-circuit + # would not work because __git_prompt_format_and_color_with_shortcircuit + # would be executed in a sub shell and setting _big_repo='yes' would not set + # the same _big_repo as is in scope in TRAPINT(). + __GIT_PROMPT_INFO="$R$_prompt$R" +} + +local _big_repo='init' +TRAPINT() +{ + if [[ "$_big_repo" == 'yes' ]]; then + _big_repo='' + if [ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]; then + echo "$fg[red]" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr + echo '' > /dev/stderr + + git config prompt.showDirtyState 'false' + __git_prompt_format_and_color_with_shortcircuit + fi + fi + return $(( 128 + $1 )) +} #------------------ setting git_prompt_info (FAST) ------------------ # To get a fast prompt I borrowed from: @@ -41,25 +162,22 @@ RPROMPT='$return_code_$R$date_$R' # This section sets up some functions that get called infrequently as possible # and therefore don't slow your prompt down as you are using zsh. -export GIT_PS1_SHOWUPSTREAM="verbose" -export GIT_PS1_SHOWSTASHSTATE='yes' -export GIT_PS1_SHOWDIRTYSTATE='yes' -export GIT_PS1_SHOWUNTRACKEDFILES='yes' - -function git_prompt_info () +git_prompt_info () { # some older versions of zsh don't have periodic_functions, so do the slow # path if that's the case: [[ $ZSH_VERSION = *\ 4.2* ]] && update_current_git_vars - echo "$__GIT_PROMPT_INFO" + + echo $__GIT_PROMPT_INFO } -function update_current_git_vars() +update_current_git_vars() { - __GIT_PROMPT_INFO="$(__git_prompt_format_and_color_with_shortcircuit)" + # sets __GIT_PROMPT_INFO: + __git_prompt_format_and_color_with_shortcircuit } -function precmd_update_git_vars() +precmd_update_git_vars() { if [ -n "$__EXECUTED_GIT_COMMAND" ]; then update_current_git_vars @@ -67,7 +185,7 @@ function precmd_update_git_vars() fi } -function preexec_update_git_vars () +preexec_update_git_vars () { case "$1" in vim*) @@ -96,10 +214,10 @@ function preexec_update_git_vars () # Enable auto-execution of functions. -typeset -ga preexec_functions -typeset -ga precmd_functions -typeset -ga chpwd_functions -typeset -ga periodic_functions +typeset -Uga preexec_functions +typeset -Uga precmd_functions +typeset -Uga chpwd_functions +typeset -Uga periodic_functions # Append git functions needed for prompt. preexec_functions+='preexec_update_git_vars' @@ -108,15 +226,13 @@ chpwd_functions+='update_current_git_vars' PERIOD=15 periodic_functions+='update_current_git_vars' - - #------------------ git information utils ------------------ # To pull information out of git, I borrowed from: # https://github.com/git/git/blob/master/contrib/completion/git-completion.bash -# __gitdir accepts 0 or 1 arguments (i.e., location) -# returns location of .git repo -__gitdir () +# __git_dir accepts 0 or 1 arguments (i.e., location) +# echos location of .git repo +__git_dir () { if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then @@ -134,8 +250,36 @@ __gitdir () } # echos divergence from upstream -# used by GIT_PS1_SHOWUPSTREAM -__git_show_upstream () +# +# Usage: +# +# divergence="$(__git_upstream)" +# +# output format: +# A "<" indicates you are behind, ">" indicates you are ahead, "<>" +# indicates you have diverged, "=" indicates no divergence, and "" indicates +# there is no upstream or this feature is turned 'off' (see below). +# +# You can control behaviour by setting GIT_PROMPT_SHOWUPSTREAM to a +# space-separated list of values: +# off no output +# verbose show number of commits ahead/behind (+/-) upstream instead +# of using "<" and ">". +# legacy don't use the '--count' option available in recent +# versions of git-rev-list +# git always compare HEAD to @{upstream} +# svn always compare HEAD to your SVN upstream +# By default, __git_upstream will compare HEAD to your SVN upstream +# if it can find one, or @{upstream} otherwise. Once you have +# set GIT_PROMPT_SHOWUPSTREAM, you can override it on a +# per-repository basis by setting the prompt.showUpstream config +# variable (i.e. `git config prompt.showUpstream 'verbose legacy'`). +# +# __git_upstream accepts 0 or 1 arguments. If an argument is given, it must be +# a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM. Setting +# this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM or in +# the .git/config. +__git_upstream () { local key value local svn_remote svn_url_pattern count n @@ -145,12 +289,8 @@ __git_show_upstream () # get some config options from git-config while read key value; do case "$key" in - prompt.showUpstream) - GIT_PS1_SHOWUPSTREAM="$value" - if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then - p="" - return - fi + prompt.showupstream*) + GIT_PROMPT_SHOWUPSTREAM="$value" ;; svn-remote.*.url) svn_remote=( "${svn_remote[@]}" $value ) @@ -158,11 +298,16 @@ __git_show_upstream () upstream=svn+git # default upstream is SVN if available, else git ;; esac - done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showUpstream)$' 2>/dev/null) + done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null) + + if [ -n "${1-}" ]; then + GIT_PROMPT_SHOWUPSTREAM=$1 + fi # parse configuration values - for option in ${GIT_PS1_SHOWUPSTREAM}; do + for option in ${GIT_PROMPT_SHOWUPSTREAM}; do case "$option" in + off) return ;; git|svn) upstream="$option" ;; verbose) verbose=1 ;; legacy) legacy=1 ;; @@ -195,7 +340,7 @@ __git_show_upstream () if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)" ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)" - count="$behind $ahead" + count="$behind $ahead" fi # calculate the result @@ -203,11 +348,11 @@ __git_show_upstream () case "$count" in "") # no upstream p="" ;; - "0 0") # equal to upstream + "0 0") # equal to upstream p="=" ;; - "0 "*) # ahead of upstream + "0 "*) # ahead of upstream p=">" ;; - *" 0") # behind upstream + *" 0") # behind upstream p="<" ;; *) # diverged from upstream p="<>" ;; @@ -216,212 +361,175 @@ __git_show_upstream () case "$count" in "") # no upstream p="" ;; - "0 0") # equal to upstream + "0 0") # equal to upstream p="=" ;; - "0 "*) # ahead of upstream - p="+${count#0 }" ;; - *" 0") # behind upstream - p="-${count% 0}" ;; + "0 "*) # ahead of upstream + p="+${count#0 }" ;; + *" 0") # behind upstream + p="-${count% 0}" ;; *) # diverged from upstream - p="-${count% *}+${count#* }" ;; + p="-${count% *}+${count#* }" ;; esac fi echo $p } -__git_show_rebase_info () +__git_rebase_info () { - local r="" - local g="$(__gitdir)" - if [ -n "$g" ]; then - if [ -f "$g/rebase-merge/interactive" ]; then - r="|REBASE-i" - elif [ -d "$g/rebase-merge" ]; then - r="|REBASE-m" - else - if [ -d "$g/rebase-apply" ]; then - if [ -f "$g/rebase-apply/rebasing" ]; then - r="|REBASE" - elif [ -f "$g/rebase-apply/applying" ]; then - r="|AM" - else - r="|AM/REBASE" - fi - elif [ -f "$g/MERGE_HEAD" ]; then - r="|MERGING" - elif [ -f "$g/CHERRY_PICK_HEAD" ]; then - r="|CHERRY-PICKING" - elif [ -f "$g/BISECT_LOG" ]; then - r="|BISECTING" - fi + if [ "$GIT_PROMPT_SHOWREBASEINFO" != 'off' ]; then + if [ "$(git config --bool prompt.showRebaseInfo)" != "false" ]; then - fi - fi - echo $r -} - -# stores the branch name in $b -__git_show_branch () -{ - local b="" - local g="$(__gitdir)" - if [ -n "$g" ]; then - if [ -f "$g/rebase-merge/interactive" ]; then - b="$(cat "$g/rebase-merge/head-name")" - elif [ -d "$g/rebase-merge" ]; then - b="$(cat "$g/rebase-merge/head-name")" - else - b="$(git symbolic-ref HEAD 2>/dev/null)" || { - - b="$( - case "${GIT_PS1_DESCRIBE_STYLE-}" in - (contains) - git describe --contains HEAD ;; - (branch) - git describe --contains --all HEAD ;; - (describe) - git describe HEAD ;; - (* | default) - git describe --tags --exact-match HEAD ;; - esac 2>/dev/null)" || - - b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" || - b="$b" - } - fi - b=${b##refs/heads/} - if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then - if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then - b="BARE:$b" - else - b="GIT_DIR!" - fi - fi - fi - echo $b -} - -__git_show_untracked_files () -{ - if [ -n "$(git ls-files --others --exclude-standard)" ]; then - echo "%" - fi -} - -__git_show_stash_state () -{ - git rev-parse --verify refs/stash >/dev/null 2>&1 && echo "$" -} - -__git_show_dirty_state_unstaged () -{ - git diff --no-ext-diff --quiet --exit-code || echo "*" -} - -__git_show_dirty_state_staged () -{ - if git rev-parse --quiet --verify HEAD >/dev/null; then - git diff-index --cached --quiet HEAD -- || echo "+" - else - echo "#" - fi -} - -#----------------------------------------------------- -__git_prompt_format_and_color_with_shortcircuit () -{ - local g="$(__gitdir)" - if [ -n "$g" ]; then - local w="" # workspace state - local s="" # stash state - local i="" # index state - local si="" # stash + index state - local u="" # untracked files state - local p="" # u'p'stream state - local b="$(__git_show_branch)" # branch - local r="$(__git_show_rebase_info)" # rebase info - if [ -n "$r" ]; then - r="$_Crebase_$r$R" - fi - - - if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then - if [ "$(git config --bool prompt.showDirtyState)" != "false" ]; then - - if [ -z "$(eval print \$_big_repo$$)" ]; then - # This is the short circuit logic: - # The following 3 functions can take a long time on big - # repositories, so check to see if ctrl-c is entered by - # setting _big_repo$$ for the duration of these functions: - eval _big_repo$$='yes' - - i="$(__git_show_dirty_state_staged)" - if [ "$i" = "+" ]; then - i="$_Ci_$i$R" - fi - - w="$(__git_show_dirty_state_unstaged)" - if [ -n "$b" ]; then - if [ "$i" = "#" ]; then - # this is a fresh repo, nothing here... - b="$_Cb_new_repo_$b$R" - i='' - elif [ -n "$w" ]; then - b="$_Cb_dirty_$b$R" - else - b="$_Cb_clean_$b$R" - fi - fi - - if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then - u="$(__git_show_untracked_files)" - fi - else - echo "$fg[red]" - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big repositories it takes a long time to get git info for your prompt." - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So I'm setting \`git config prompt.showDirtyState false\` on this repository because you hit ctrl-c." - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" - echo '' - git config prompt.showDirtyState 'false' - fi - unset _big_repo$$ - fi - fi - - - if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then - s="$(__git_show_stash_state)" - fi - - if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then - p="$(__git_show_upstream)" - fi - si="$i$s" - if [ -n "$s$p" ]; then - i+="$R" - p="$_Cp_$p$R" - s="$_Cs_$s$R" - fi - else - unset _big_repo$$ - fi - - local _prompt="$b$r${si:+$i$s}$p" - - # add ( ) around _prompt: - if [ -z "$w$i$u$b" ]; then + local r="" + local g="$(__git_dir)" if [ -n "$g" ]; then - _prompt="$_Cerror_(Error: bad ./$g dir)" - fi - elif [ -n "$u" ]; then - _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" - else - _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" - fi + if [ -f "$g/rebase-merge/interactive" ]; then + r="|REBASE-i" + elif [ -d "$g/rebase-merge" ]; then + r="|REBASE-m" + else + if [ -d "$g/rebase-apply" ]; then + if [ -f "$g/rebase-apply/rebasing" ]; then + r="|REBASE" + elif [ -f "$g/rebase-apply/applying" ]; then + r="|AM" + else + r="|AM/REBASE" + fi + elif [ -f "$g/MERGE_HEAD" ]; then + r="|MERGING" + elif [ -f "$g/CHERRY_PICK_HEAD" ]; then + r="|CHERRY-PICKING" + elif [ -f "$g/BISECT_LOG" ]; then + r="|BISECTING" + fi - echo "$R$_prompt$R" + fi + fi + echo $r + + fi fi } + +__git_branch () +{ + if [ "$GIT_PROMPT_SHOWBRANCH" != 'off' ]; then + if [ "$(git config --bool prompt.showBranch)" != "false" ]; then + + local b="" + local g="$(__git_dir)" + if [ -n "$g" ]; then + if [ -f "$g/rebase-merge/interactive" ]; then + b="$(cat "$g/rebase-merge/head-name")" + elif [ -d "$g/rebase-merge" ]; then + b="$(cat "$g/rebase-merge/head-name")" + else + b="$(git symbolic-ref HEAD 2>/dev/null)" || { + + b="$( + case "${GIT_PROMPT_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --tags --exact-match HEAD ;; + esac 2>/dev/null)" || + + b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" || + b="$b" + } + fi + b=${b##refs/heads/} + if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then + if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then + b="BARE:$b" + else + b="GIT_DIR!" + fi + fi + fi + echo $b + + fi + fi +} + +__git_dirty_state_untracked_files () +{ + if [ "$GIT_PROMPT_SHOWUNTRACKEDFILES" != 'off' ]; then + if [ "$(git config --bool prompt.showUntrackedFiles)" != "false" ]; then + if [ -n "$(git ls-files --others --exclude-standard)" ]; then + echo ${GIT_PROMPT_SHOWUNTRACKEDFILES_DIRTY_MARK-dirty} + else + echo ${GIT_PROMPT_SHOWUNTRACKEDFILES_CLEAN_MARK-clean} + fi + return + fi + fi + echo ${GIT_PROMPT_FEATURE_OFF-feature_off} +} + + +__git_stash_state () +{ + if [ "$GIT_PROMPT_SHOWSTASHSTATE" != 'off' ]; then + if [ "$(git config --bool prompt.showStashState)" != "false" ]; then + if git rev-parse --verify refs/stash >/dev/null 2>&1; then + echo ${GIT_PROMPT_SHOWSTASHSTATE_DIRTY_MARK-dirty} + else + echo ${GIT_PROMPT_SHOWSTASHSTATE_CLEAN_MARK-clean} + fi + return + fi + fi + echo ${GIT_PROMPT_FEATURE_OFF-feature_off} +} + + +__git_dirty_state_unstaged () +{ + if [ "$GIT_PROMPT_DIRTYSTATEUNSTAGED" != 'off' ]; then + if [ "$(git config --bool prompt.showDirtyStateUnstaged)" != "false" ]; then + if git rev-parse --quiet --verify HEAD >/dev/null; then + if git diff --no-ext-diff --quiet --exit-code; then + echo ${GIT_PROMPT_DIRTYSTATEUNSTAGED_CLEAN_MARK-clean} + else + echo ${GIT_PROMPT_DIRTYSTATEUNSTAGED_DIRTY_MARK-dirty} + fi + else + echo ${GIT_PROMPT_FRESH_REPO-fresh} + fi + return + fi + fi + echo ${GIT_PROMPT_FEATURE_OFF-feature_off} +} + +__git_dirty_state_staged () +{ + if [ "$GIT_PROMPT_DIRTYSTATESTAGED" != 'off' ]; then + if [ "$(git config --bool prompt.showDirtyStateStaged)" != "false" ]; then + if git rev-parse --quiet --verify HEAD >/dev/null; then + # if this isn't a fresh repo: + if git diff-index --cached --quiet HEAD --; then + echo ${GIT_PROMPT_DIRTYSTATESTAGED_CLEAN_MARK-clean} + else + echo ${GIT_PROMPT_DIRTYSTATESTAGED_DIRTY_MARK-dirty} + fi + else + # else take the slower route + local num_index_files="$(git status --porcelain | egrep '^[MADRCU]' | wc -l | tr -d ' ')" + if [ $num_index_files = 0 ]; then + echo ${GIT_PROMPT_DIRTYSTATESTAGED_CLEAN_MARK-clean} + else + echo ${GIT_PROMPT_DIRTYSTATESTAGED_DIRTY_MARK-dirty} + fi + fi + return + fi + fi + echo ${GIT_PROMPT_FEATURE_OFF-feature_off} +} From 541b16d931ad17e0cecf5cc3e9041b9ad721be00 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Wed, 18 May 2011 21:41:19 -0700 Subject: [PATCH 03/29] Split ashleydev them into a plugin and the theme. --- plugins/git-prompt/git-prompt.plugin.zsh | 602 +++++++++++++++++++++++ themes/ashleydev.zsh-theme | 483 ++---------------- 2 files changed, 639 insertions(+), 446 deletions(-) create mode 100644 plugins/git-prompt/git-prompt.plugin.zsh diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh new file mode 100644 index 000000000..db67a0d6f --- /dev/null +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -0,0 +1,602 @@ +# USAGE: +# +# This example shows some of the things you in this plugin. This is how the +# author uses it: +# +# ---------------------- SAMPLE THEME FILE ------------------------ +# +# # this is a simple example PROMPT with only git info in it: +# PROMPT='$__GIT_PROMPT_INFO# ' +# +# +# # Set GIT_PROMPT_SHORTCIRCUIT='off' to turn the +# # short-circuit logic off. The short-circuit +# # logic will turn off the showing of dirty +# # state in your git prompt if ctrl-c is pressed +# # while the prompt is updating the dirty state +# # info. Gathering dirty-state info can take a +# # long time on large repositories, so if you +# # find that you're prompt is taking for ever to +# # show up, and you press ctrl-c, the short- +# # circuit logic will turn of the showing of +# # dirty state for this repository (locally) and +# # let you know, that way you won't be slowed +# # down waiting for your prompt in large git +# # repositories. +# GIT_PROMPT_SHORTCIRCUIT='on' +# +# # GIT_PROMPT_INFO_FUNC must be set to the +# # function that defines your prompt info +# # inorder to turn the git-prompt plugin on. +# GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO' +# +# GIT_PROMPT_SHOWUPSTREAM="verbose" +# +# if [[ -z $__git_prompt_loaded__ && +# -f $ZSH/plugins/git-prompt/git-prompt.plugin.zsh ]]; +# then +# source $ZSH/plugins/git-prompt/git-prompt.plugin.zsh +# fi +# +# +# # Some color settings for the format +# # '_C' for color: +# local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory +# local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo +# local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean +# local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty +# local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info +# local _Ci_="%{$bold_color$fg[red]%}" # index info +# local _Cu_clean_="" # untracked files state when clean +# local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty +# local _Cp_="%{${fg[cyan]}%}" # upstream info +# local _Cs_="" # stash state +# # 'R'eset formating +# local R="%{$terminfo[sgr0]%}" +# +# # This function creates the format and content +# # of the git prompt info. It shows some of the +# # ways you can set up your prompt with this +# # plugin. +# # +# # This function must set a global variable (with +# # the your git prompt format) that you include in +# # your PROMPT string. +# # NOTE: it cannot echo this info as in: +# # PROMPT="$(update__GIT_PROMPT_INFO)" +# # or the short-circuit logic will not work. +# # +# local __GIT_PROMPT_INFO='' +# update__GIT_PROMPT_INFO () +# { +# local g="$(__git_dir)" +# if [ -z "$g" ]; then +# __GIT_PROMPT_INFO='' +# return +# fi +# +# __git_stash_state +# local s=$GIT_PROMPT_STASH_STATE_DIRTY +# +# __git_upstream +# local p=$GIT_PROMPT_UPSTREAM_STATE +# +# __git_branch +# local b=$GIT_PROMPT_BRANCH +# +# __git_rebase_info +# local r=$GIT_PROMPT_REBASE_INFO +# +# __git_dirty_state +# local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY +# local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY +# local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED +# local f=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO +# +# if [ -z "$b$i$w$u" ]; then +# if [ -n "$g" ]; then +# __GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R" +# return +# fi +# fi +# +# if [ "$s" = 'yes' ]; then +# s="$_Cs_\$$R" +# else +# s="" +# fi +# +# if [ -n "$p" ]; then +# p="$_Cp_$p$R" +# fi +# +# if [ "$i" = "yes" ]; then +# i="$_Ci_+$R" +# else +# i="" +# fi +# +# if [ -n "$b" ]; then +# if [ "$f" = "yes" ]; then +# # this is a fresh repo, nothing here... +# b="$_Cb_new_repo_$b$R" +# elif [ "$w" = 'yes' ]; then +# b="$_Cb_dirty_$b$R" +# elif [ "$w" = 'no' ]; then +# b="$_Cb_clean_$b$R" +# fi +# fi +# +# if [ -n "$r" ]; then +# r="$_Cr_$r$R" +# fi +# +# local _prompt="$b$r$s$i$p" +# # add ( ) around _prompt: +# if [ $f = 'yes' ]; then +# _prompt="($_prompt)" +# elif [ "$u" = "yes" ]; then +# _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" +# elif [ "$u" = "no" ]; then +# _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" +# else +# fi +# +# __GIT_PROMPT_INFO="$R$_prompt$R" +# } +# ----------------------------------------------------------------- +# +# + + +#------------------ git information utils ------------------ +# To pull information out of git, I borrowed from: +# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash +# + + +# __git_dir accepts 0 or 1 arguments (i.e., location) +# echos location of .git repo +__git_dir () +{ + if [ -z "${1-}" ]; then + if [ -n "${__git_dir-}" ]; then + echo "$__git_dir" + elif [ -d .git ]; then + echo .git + else + git rev-parse --git-dir 2>/dev/null + fi + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# sets GIT_PROMPT_UPSTREAM_STATE +# +# output format: +# A "<" indicates you are behind, ">" indicates you are ahead, "<>" +# indicates you have diverged, "=" indicates no divergence, and "" indicates +# there is no upstream or this feature is turned 'off' (see below). +# +# You can control behaviour by setting GIT_PROMPT_SHOWUPSTREAM to a +# space-separated list of values: +# off no output +# verbose show number of commits ahead/behind (+/-) upstream instead +# of using "<" and ">". +# legacy don't use the '--count' option available in recent +# versions of git-rev-list +# git always compare HEAD to @{upstream} +# svn always compare HEAD to your SVN upstream +# By default, __git_upstream will compare HEAD to your SVN upstream +# if it can find one, or @{upstream} otherwise. Once you have +# set GIT_PROMPT_SHOWUPSTREAM, you can override it on a +# per-repository basis by setting the prompt.showUpstream config +# variable (i.e. `git config prompt.showUpstream 'verbose legacy'`). +# +# __git_upstream accepts 0 or 1 arguments. If an argument is given, it must be +# a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM. Setting +# this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM or in +# the .git/config. +__git_upstream () +{ + GIT_PROMPT_UPSTREAM_STATE='' + + if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + return + fi + + local key value + local svn_remote svn_url_pattern count n + local upstream=git legacy="" verbose="" + local p + + # get some config options from git-config + while read key value; do + case "$key" in + prompt.showupstream*) + GIT_PROMPT_SHOWUPSTREAM="$value" + ;; + svn-remote.*.url) + svn_remote=( "${svn_remote[@]}" $value ) + svn_url_pattern="$svn_url_pattern\\|$value" + upstream=svn+git # default upstream is SVN if available, else git + ;; + esac + done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null) + + if [ -n "${1-}" ]; then + GIT_PROMPT_SHOWUPSTREAM=$1 + fi + + # parse configuration values + for option in ${GIT_PROMPT_SHOWUPSTREAM}; do + case "$option" in + off) return ;; + git|svn) upstream="$option" ;; + verbose) verbose=1 ;; + legacy) legacy=1 ;; + esac + done + + # Find our upstream + case "$upstream" in + git) upstream="@{upstream}" ;; + svn*) + # get the upstream from the "git-svn-id: ..." in a commit message + # (git-svn uses essentially the same procedure internally) + local svn_upstream=$(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null | awk '/commit / { print $2 }') + if [[ 0 -ne ${#svn_upstream[@]} ]]; then + if [[ -z "$svn_upstream" ]]; then + # default branch name for checkouts with no layout: + upstream='git-svn' + else + upstream=${svn_upstream#/} + fi + elif [[ "svn+git" = "$upstream" ]]; then + upstream="@{upstream}" + fi + ;; + esac + + # Find how many commits we are ahead/behind our upstream + # produce equivalent output to --count for older versions of git + local ahead behind + if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then + behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)" + ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)" + count="$behind $ahead" + fi + + # calculate the result + if [[ -z "$verbose" ]]; then + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p=">" ;; + *" 0") # behind upstream + p="<" ;; + *) # diverged from upstream + p="<>" ;; + esac + else + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p="+${count#0 }" ;; + *" 0") # behind upstream + p="-${count% 0}" ;; + *) # diverged from upstream + p="-${count% *}+${count#* }" ;; + esac + fi + + GIT_PROMPT_UPSTREAM_STATE=$p +} + +__git_rebase_info () +{ + GIT_PROMPT_REBASE_INFO='' + + if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + return + fi + if [ "$GIT_PROMPT_SHOWREBASEINFO" = 'off' ]; then + return + fi + if [ "$(git config --bool prompt.showRebaseInfo)" = "false" ]; then + return + fi + + local r="" + local g="$(__git_dir)" + if [ -n "$g" ]; then + if [ -f "$g/rebase-merge/interactive" ]; then + r="|REBASE-i" + elif [ -d "$g/rebase-merge" ]; then + r="|REBASE-m" + else + if [ -d "$g/rebase-apply" ]; then + if [ -f "$g/rebase-apply/rebasing" ]; then + r="|REBASE" + elif [ -f "$g/rebase-apply/applying" ]; then + r="|AM" + else + r="|AM/REBASE" + fi + elif [ -f "$g/MERGE_HEAD" ]; then + r="|MERGING" + elif [ -f "$g/CHERRY_PICK_HEAD" ]; then + r="|CHERRY-PICKING" + elif [ -f "$g/BISECT_LOG" ]; then + r="|BISECTING" + fi + + fi + fi + + GIT_PROMPT_REBASE_INFO=$r +} + +__git_branch () +{ + GIT_PROMPT_BRANCH='' + + if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + return + fi + + if [ "$GIT_PROMPT_SHOWBRANCH" = 'off' ]; then + return + fi + if [ "$(git config --bool prompt.showBranch)" = "false" ]; then + return + fi + + local b="" + local g="$(__git_dir)" + if [ -n "$g" ]; then + if [ -f "$g/rebase-merge/interactive" ]; then + b="$(cat "$g/rebase-merge/head-name")" + elif [ -d "$g/rebase-merge" ]; then + b="$(cat "$g/rebase-merge/head-name")" + else + b="$(git symbolic-ref HEAD 2>/dev/null)" || { + + b="$( + case "${GIT_PROMPT_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --tags --exact-match HEAD ;; + esac 2>/dev/null)" || + + b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" || + b="$b" + } + fi + b=${b##refs/heads/} + if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then + if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then + b="BARE:$b" + else + b="GIT_DIR!" + fi + fi + fi + + GIT_PROMPT_BRANCH=$b +} + + +__git_stash_state () +{ + GIT_PROMPT_STASH_STATE_DIRTY='' + + if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + return + fi + + if [ "$GIT_PROMPT_SHOWSTASHSTATE" = 'off' ]; then + return + fi + if [ "$(git config --bool prompt.showStashState)" = "false" ]; then + return + fi + + if git rev-parse --verify refs/stash >/dev/null 2>&1; then + GIT_PROMPT_STASH_STATE_DIRTY='yes' + else + GIT_PROMPT_STASH_STATE_DIRTY='no' + fi +} + + +# This is the short-circuit logic: +local _big_repo='init' +TRAPINT() +{ + if [[ "$_big_repo" == 'yes' ]]; then + _big_repo='' + if [ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]; then + echo "$fg[red]" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr + echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr + echo '' > /dev/stderr + + git config prompt.showDirtyState 'false' + $GIT_PROMPT_INFO_FUNC + fi + fi + return $(( 128 + $1 )) +} +__git_dirty_state () +{ + GIT_PROMPT_DIRTY_STATE_FRESH_REPO='' + GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='' + GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='' + GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='' + GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='' + GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='' + GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='' + GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='' + + if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + return + fi + + local g="$(__git_dir)" + if [ -z "$g" ]; then + return + fi + if [ "$GIT_PROMPT_SHOWDIRTYSTATE" = 'off' ]; then + return + fi + if [ "$(git config --bool prompt.showDirtyState)" = "false" ]; then + return + fi + + GIT_PROMPT_DIRTY_STATE_FRESH_REPO='no' + GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='no' + GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='no' + GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='no' + GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='no' + + if git rev-parse --quiet --verify HEAD >/dev/null; then + else + GIT_PROMPT_DIRTY_STATE_FRESH_REPO='yes' + fi + + _big_repo='yes' + local line + while IFS=$'\n' read line; do + if [[ "$line" =~ '^M' ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + fi + if [[ "$line" =~ '^A' ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + fi + if [[ "$line" =~ '^R' ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + fi + if [[ "$line" =~ '^C' ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + fi + if [[ "$line" =~ '^D' ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + fi + + if [[ "$line" =~ '^\?\? ' ]]; then + GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' + fi + if [[ "$line" =~ '^ M' ]]; then + GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' + fi + if [[ "$line" =~ '^ D' ]]; then + GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='yes' + GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' + fi + + if [[ "$line" =~ '^UU' ]]; then + GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='yes' + GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' + fi + done < <(git status --porcelain 2> /dev/null) + _big_repo='' +} + +#------------------ Fast Prompt ------------------ +# This section sets up some functions that get called infrequently as possible +# and therefore don't slow your prompt down as you are using zsh. +# +# I borrowed from: http://sebastiancelis.com/2009/nov/16/zsh-prompt-git-users/ + +# Enable auto-execution of functions. +typeset -Uga preexec_functions +typeset -Uga precmd_functions +typeset -Uga chpwd_functions +typeset -Uga periodic_functions + +# Append git functions needed for prompt. +preexec_functions+='preexec_update_git_vars' +precmd_functions+='precmd_update_git_vars' +chpwd_functions+="$GIT_PROMPT_INFO_FUNC" +PERIOD=15 +periodic_functions+="$GIT_PROMPT_INFO_FUNC" + +precmd_update_git_vars() +{ + if [[ $ZSH_VERSION = *\ 4.2* ]]; then + # some older versions of zsh don't have periodic_functions, so do the + # slow path if that's the case: + $GIT_PROMPT_INFO_FUNC + + elif [ -n "$__EXECUTED_GIT_COMMAND" ]; then + $GIT_PROMPT_INFO_FUNC + unset __EXECUTED_GIT_COMMAND + fi +} + +preexec_update_git_vars () +{ + case "$1" in + vim*) + __EXECUTED_GIT_COMMAND=1 + ;; + g*) + __EXECUTED_GIT_COMMAND=1 + ;; + rm*) + __EXECUTED_GIT_COMMAND=1 + ;; + touch*) + __EXECUTED_GIT_COMMAND=1 + ;; + mkdir*) + __EXECUTED_GIT_COMMAND=1 + ;; +# f) +# __EXECUTED_GIT_COMMAND=1 +# ;; +# fg) +# __EXECUTED_GIT_COMMAND=1 +# ;; + esac +} + +#-------------------------------------------------- +__git_prompt_loaded__='yes' diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index 008f4e1fb..3938ebe3c 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -1,7 +1,7 @@ #-------------------- PROMPT definition: ---------------------- # Set the prompt. -# 'R'eset formating +# Reset formating local R="%{$terminfo[sgr0]%}" # special colors for privileged users (root) @@ -10,7 +10,7 @@ local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m$R" local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~$R" local jobs_="%(1j.%{$fg[blue]%}%j$R.)" -PROMPT='$user_$host_$path_ $(git_prompt_info)$jobs_# ' +PROMPT='$user_$host_$path_ $__GIT_PROMPT_INFO$jobs_# ' local date_format_="%D{%a %b %d}, %*" local date_="%{$fg[green]%}[$date_format_]" @@ -21,10 +21,17 @@ RPROMPT='$return_code_$R$date_$R' # use the vi-mode oh-my-zsh plugin to get this: MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" +# #----------------------------------------------------- # git prompt info: -local GIT_PROMPT_SHOWUPSTREAM="verbose" +GIT_PROMPT_SHOWUPSTREAM="verbose" +GIT_PROMPT_SHORTCIRCUIT='on' +GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO" +if [[ -z $__git_prompt_loaded__ && + -f $ZSH/plugins/git-prompt/git-prompt.plugin.zsh ]]; then + source $ZSH/plugins/git-prompt/git-prompt.plugin.zsh +fi # git_prompt_info colors ('_C' for color): local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory @@ -38,8 +45,9 @@ local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty local _Cp_="%{${fg[cyan]}%}" # upstream info local _Cs_="" # stash state +local __GIT_PROMPT_INFO='' # will set __GIT_PROMPT_INFO -__git_prompt_format_and_color_with_shortcircuit () +update__GIT_PROMPT_INFO () { local g="$(__git_dir)" if [ -z "$g" ]; then @@ -47,32 +55,23 @@ __git_prompt_format_and_color_with_shortcircuit () return fi - local w="" # workspace state - local s="" # stash state - local i="" # index state - local u="" # untracked files state - local p="" # u'p'stream state - local b="$(__git_branch)" # branch - local r="$(__git_rebase_info)" # rebase info + __git_stash_state + local s=$GIT_PROMPT_STASH_STATE_DIRTY - if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then - if [ "$GIT_PROMPT_SHOWDIRTYSTATE" != 'off' ]; then - if [ "$(git config --bool prompt.showDirtyState)" != "false" ]; then - # This is the short circuit logic: - # The following 3 functions can take a long time on big - # repositories, so check to see if ctrl-c is entered by - # setting _big_repo for the duration of these functions: - # (Then check for _big_repo in TRAPINT().) - _big_repo='yes' - i="$(__git_dirty_state_staged)" - w="$(__git_dirty_state_unstaged)" - u="$(__git_dirty_state_untracked_files)" - _big_repo='' - fi - fi - s="$(__git_stash_state)" - p="$(__git_upstream)" - fi + __git_upstream + local p=$GIT_PROMPT_UPSTREAM_STATE + + __git_branch + local b=$GIT_PROMPT_BRANCH + + __git_rebase_info + local r=$GIT_PROMPT_REBASE_INFO + + __git_dirty_state + local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY + local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY + local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED + local f=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO if [ -z "$b$i$w$u" ]; then if [ -n "$g" ]; then @@ -81,7 +80,7 @@ __git_prompt_format_and_color_with_shortcircuit () fi fi - if [ "$s" = 'dirty' ]; then + if [ "$s" = 'yes' ]; then s="$_Cs_\$$R" else s="" @@ -91,19 +90,19 @@ __git_prompt_format_and_color_with_shortcircuit () p="$_Cp_$p$R" fi - if [ "$i" = "dirty" ]; then + if [ "$i" = "yes" ]; then i="$_Ci_+$R" else i="" fi if [ -n "$b" ]; then - if [ "$w" = "fresh" ]; then + if [ "$f" = "yes" ]; then # this is a fresh repo, nothing here... b="$_Cb_new_repo_$b$R" - elif [ "$w" = 'dirty' ]; then + elif [ "$w" = 'yes' ]; then b="$_Cb_dirty_$b$R" - elif [ "$w" = 'clean' ]; then + elif [ "$w" = 'no' ]; then b="$_Cb_clean_$b$R" fi fi @@ -113,423 +112,15 @@ __git_prompt_format_and_color_with_shortcircuit () fi local _prompt="$b$r$s$i$p" - # add ( ) around _prompt: - if [ "$u" = "dirty" ]; then + if [ $f = 'yes' ]; then + _prompt="($_prompt)" + elif [ "$u" = "yes" ]; then _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" - elif [ "$u" = "clean" ]; then + elif [ "$u" = "no" ]; then _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" else - _prompt="($_prompt)" fi - # NOTE: This function must set __GIT_PROMPT_INFO to return it's value, - # rather than echo'ing it for the caller to call it as: - # __GIT_PROMPT_INFO=$(__git_prompt_format_and_color_with_shortcircuit) - # because if we were to call this function in $(...), then the short-circuit - # would not work because __git_prompt_format_and_color_with_shortcircuit - # would be executed in a sub shell and setting _big_repo='yes' would not set - # the same _big_repo as is in scope in TRAPINT(). __GIT_PROMPT_INFO="$R$_prompt$R" } - -local _big_repo='init' -TRAPINT() -{ - if [[ "$_big_repo" == 'yes' ]]; then - _big_repo='' - if [ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]; then - echo "$fg[red]" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr - echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr - echo '' > /dev/stderr - - git config prompt.showDirtyState 'false' - __git_prompt_format_and_color_with_shortcircuit - fi - fi - return $(( 128 + $1 )) -} - -#------------------ setting git_prompt_info (FAST) ------------------ -# To get a fast prompt I borrowed from: -# http://sebastiancelis.com/2009/nov/16/zsh-prompt-git-users/ -# -# This section sets up some functions that get called infrequently as possible -# and therefore don't slow your prompt down as you are using zsh. - -git_prompt_info () -{ - # some older versions of zsh don't have periodic_functions, so do the slow - # path if that's the case: - [[ $ZSH_VERSION = *\ 4.2* ]] && update_current_git_vars - - echo $__GIT_PROMPT_INFO -} - -update_current_git_vars() -{ - # sets __GIT_PROMPT_INFO: - __git_prompt_format_and_color_with_shortcircuit -} - -precmd_update_git_vars() -{ - if [ -n "$__EXECUTED_GIT_COMMAND" ]; then - update_current_git_vars - unset __EXECUTED_GIT_COMMAND - fi -} - -preexec_update_git_vars () -{ - case "$1" in - vim*) - __EXECUTED_GIT_COMMAND=1 - ;; - g*) - __EXECUTED_GIT_COMMAND=1 - ;; - rm*) - __EXECUTED_GIT_COMMAND=1 - ;; - touch*) - __EXECUTED_GIT_COMMAND=1 - ;; - mkdir*) - __EXECUTED_GIT_COMMAND=1 - ;; -# f) -# __EXECUTED_GIT_COMMAND=1 -# ;; -# fg) -# __EXECUTED_GIT_COMMAND=1 -# ;; - esac -} - - -# Enable auto-execution of functions. -typeset -Uga preexec_functions -typeset -Uga precmd_functions -typeset -Uga chpwd_functions -typeset -Uga periodic_functions - -# Append git functions needed for prompt. -preexec_functions+='preexec_update_git_vars' -precmd_functions+='precmd_update_git_vars' -chpwd_functions+='update_current_git_vars' -PERIOD=15 -periodic_functions+='update_current_git_vars' - -#------------------ git information utils ------------------ -# To pull information out of git, I borrowed from: -# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash - -# __git_dir accepts 0 or 1 arguments (i.e., location) -# echos location of .git repo -__git_dir () -{ - if [ -z "${1-}" ]; then - if [ -n "${__git_dir-}" ]; then - echo "$__git_dir" - elif [ -d .git ]; then - echo .git - else - git rev-parse --git-dir 2>/dev/null - fi - elif [ -d "$1/.git" ]; then - echo "$1/.git" - else - echo "$1" - fi -} - -# echos divergence from upstream -# -# Usage: -# -# divergence="$(__git_upstream)" -# -# output format: -# A "<" indicates you are behind, ">" indicates you are ahead, "<>" -# indicates you have diverged, "=" indicates no divergence, and "" indicates -# there is no upstream or this feature is turned 'off' (see below). -# -# You can control behaviour by setting GIT_PROMPT_SHOWUPSTREAM to a -# space-separated list of values: -# off no output -# verbose show number of commits ahead/behind (+/-) upstream instead -# of using "<" and ">". -# legacy don't use the '--count' option available in recent -# versions of git-rev-list -# git always compare HEAD to @{upstream} -# svn always compare HEAD to your SVN upstream -# By default, __git_upstream will compare HEAD to your SVN upstream -# if it can find one, or @{upstream} otherwise. Once you have -# set GIT_PROMPT_SHOWUPSTREAM, you can override it on a -# per-repository basis by setting the prompt.showUpstream config -# variable (i.e. `git config prompt.showUpstream 'verbose legacy'`). -# -# __git_upstream accepts 0 or 1 arguments. If an argument is given, it must be -# a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM. Setting -# this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM or in -# the .git/config. -__git_upstream () -{ - local key value - local svn_remote svn_url_pattern count n - local upstream=git legacy="" verbose="" - local p - - # get some config options from git-config - while read key value; do - case "$key" in - prompt.showupstream*) - GIT_PROMPT_SHOWUPSTREAM="$value" - ;; - svn-remote.*.url) - svn_remote=( "${svn_remote[@]}" $value ) - svn_url_pattern="$svn_url_pattern\\|$value" - upstream=svn+git # default upstream is SVN if available, else git - ;; - esac - done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null) - - if [ -n "${1-}" ]; then - GIT_PROMPT_SHOWUPSTREAM=$1 - fi - - # parse configuration values - for option in ${GIT_PROMPT_SHOWUPSTREAM}; do - case "$option" in - off) return ;; - git|svn) upstream="$option" ;; - verbose) verbose=1 ;; - legacy) legacy=1 ;; - esac - done - - # Find our upstream - case "$upstream" in - git) upstream="@{upstream}" ;; - svn*) - # get the upstream from the "git-svn-id: ..." in a commit message - # (git-svn uses essentially the same procedure internally) - local svn_upstream=$(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null | awk '/commit / { print $2 }') - if [[ 0 -ne ${#svn_upstream[@]} ]]; then - if [[ -z "$svn_upstream" ]]; then - # default branch name for checkouts with no layout: - upstream='git-svn' - else - upstream=${svn_upstream#/} - fi - elif [[ "svn+git" = "$upstream" ]]; then - upstream="@{upstream}" - fi - ;; - esac - - # Find how many commits we are ahead/behind our upstream - # produce equivalent output to --count for older versions of git - local ahead behind - if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then - behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)" - ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)" - count="$behind $ahead" - fi - - # calculate the result - if [[ -z "$verbose" ]]; then - case "$count" in - "") # no upstream - p="" ;; - "0 0") # equal to upstream - p="=" ;; - "0 "*) # ahead of upstream - p=">" ;; - *" 0") # behind upstream - p="<" ;; - *) # diverged from upstream - p="<>" ;; - esac - else - case "$count" in - "") # no upstream - p="" ;; - "0 0") # equal to upstream - p="=" ;; - "0 "*) # ahead of upstream - p="+${count#0 }" ;; - *" 0") # behind upstream - p="-${count% 0}" ;; - *) # diverged from upstream - p="-${count% *}+${count#* }" ;; - esac - fi - echo $p -} - -__git_rebase_info () -{ - if [ "$GIT_PROMPT_SHOWREBASEINFO" != 'off' ]; then - if [ "$(git config --bool prompt.showRebaseInfo)" != "false" ]; then - - local r="" - local g="$(__git_dir)" - if [ -n "$g" ]; then - if [ -f "$g/rebase-merge/interactive" ]; then - r="|REBASE-i" - elif [ -d "$g/rebase-merge" ]; then - r="|REBASE-m" - else - if [ -d "$g/rebase-apply" ]; then - if [ -f "$g/rebase-apply/rebasing" ]; then - r="|REBASE" - elif [ -f "$g/rebase-apply/applying" ]; then - r="|AM" - else - r="|AM/REBASE" - fi - elif [ -f "$g/MERGE_HEAD" ]; then - r="|MERGING" - elif [ -f "$g/CHERRY_PICK_HEAD" ]; then - r="|CHERRY-PICKING" - elif [ -f "$g/BISECT_LOG" ]; then - r="|BISECTING" - fi - - fi - fi - echo $r - - fi - fi -} - -__git_branch () -{ - if [ "$GIT_PROMPT_SHOWBRANCH" != 'off' ]; then - if [ "$(git config --bool prompt.showBranch)" != "false" ]; then - - local b="" - local g="$(__git_dir)" - if [ -n "$g" ]; then - if [ -f "$g/rebase-merge/interactive" ]; then - b="$(cat "$g/rebase-merge/head-name")" - elif [ -d "$g/rebase-merge" ]; then - b="$(cat "$g/rebase-merge/head-name")" - else - b="$(git symbolic-ref HEAD 2>/dev/null)" || { - - b="$( - case "${GIT_PROMPT_DESCRIBE_STYLE-}" in - (contains) - git describe --contains HEAD ;; - (branch) - git describe --contains --all HEAD ;; - (describe) - git describe HEAD ;; - (* | default) - git describe --tags --exact-match HEAD ;; - esac 2>/dev/null)" || - - b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" || - b="$b" - } - fi - b=${b##refs/heads/} - if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then - if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then - b="BARE:$b" - else - b="GIT_DIR!" - fi - fi - fi - echo $b - - fi - fi -} - -__git_dirty_state_untracked_files () -{ - if [ "$GIT_PROMPT_SHOWUNTRACKEDFILES" != 'off' ]; then - if [ "$(git config --bool prompt.showUntrackedFiles)" != "false" ]; then - if [ -n "$(git ls-files --others --exclude-standard)" ]; then - echo ${GIT_PROMPT_SHOWUNTRACKEDFILES_DIRTY_MARK-dirty} - else - echo ${GIT_PROMPT_SHOWUNTRACKEDFILES_CLEAN_MARK-clean} - fi - return - fi - fi - echo ${GIT_PROMPT_FEATURE_OFF-feature_off} -} - - -__git_stash_state () -{ - if [ "$GIT_PROMPT_SHOWSTASHSTATE" != 'off' ]; then - if [ "$(git config --bool prompt.showStashState)" != "false" ]; then - if git rev-parse --verify refs/stash >/dev/null 2>&1; then - echo ${GIT_PROMPT_SHOWSTASHSTATE_DIRTY_MARK-dirty} - else - echo ${GIT_PROMPT_SHOWSTASHSTATE_CLEAN_MARK-clean} - fi - return - fi - fi - echo ${GIT_PROMPT_FEATURE_OFF-feature_off} -} - - -__git_dirty_state_unstaged () -{ - if [ "$GIT_PROMPT_DIRTYSTATEUNSTAGED" != 'off' ]; then - if [ "$(git config --bool prompt.showDirtyStateUnstaged)" != "false" ]; then - if git rev-parse --quiet --verify HEAD >/dev/null; then - if git diff --no-ext-diff --quiet --exit-code; then - echo ${GIT_PROMPT_DIRTYSTATEUNSTAGED_CLEAN_MARK-clean} - else - echo ${GIT_PROMPT_DIRTYSTATEUNSTAGED_DIRTY_MARK-dirty} - fi - else - echo ${GIT_PROMPT_FRESH_REPO-fresh} - fi - return - fi - fi - echo ${GIT_PROMPT_FEATURE_OFF-feature_off} -} - -__git_dirty_state_staged () -{ - if [ "$GIT_PROMPT_DIRTYSTATESTAGED" != 'off' ]; then - if [ "$(git config --bool prompt.showDirtyStateStaged)" != "false" ]; then - if git rev-parse --quiet --verify HEAD >/dev/null; then - # if this isn't a fresh repo: - if git diff-index --cached --quiet HEAD --; then - echo ${GIT_PROMPT_DIRTYSTATESTAGED_CLEAN_MARK-clean} - else - echo ${GIT_PROMPT_DIRTYSTATESTAGED_DIRTY_MARK-dirty} - fi - else - # else take the slower route - local num_index_files="$(git status --porcelain | egrep '^[MADRCU]' | wc -l | tr -d ' ')" - if [ $num_index_files = 0 ]; then - echo ${GIT_PROMPT_DIRTYSTATESTAGED_CLEAN_MARK-clean} - else - echo ${GIT_PROMPT_DIRTYSTATESTAGED_DIRTY_MARK-dirty} - fi - fi - return - fi - fi - echo ${GIT_PROMPT_FEATURE_OFF-feature_off} -} From bf56eadc224afd9df49d0b8c59f267472db8d40b Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 19 May 2011 07:08:36 -0700 Subject: [PATCH 04/29] Move git-prompt from plugin/ to lib/ because it needs to be auto loaded prior to the theme being loaded. --- .../git-prompt.zsh | 20 +++++++++---------- themes/ashleydev.zsh-theme | 9 ++++----- 2 files changed, 14 insertions(+), 15 deletions(-) rename plugins/git-prompt/git-prompt.plugin.zsh => lib/git-prompt.zsh (98%) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/lib/git-prompt.zsh similarity index 98% rename from plugins/git-prompt/git-prompt.plugin.zsh rename to lib/git-prompt.zsh index db67a0d6f..aacc9cbff 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/lib/git-prompt.zsh @@ -27,18 +27,14 @@ # # # GIT_PROMPT_INFO_FUNC must be set to the # # function that defines your prompt info -# # inorder to turn the git-prompt plugin on. +# # in order to turn the git-prompt plugin on. +# # $ZSH/lib/git-prompt.zsh will cause +# # $GIT_PROMPT_INFO_FUNC to be called when the +# # git prompt info needs to be updated. # GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO' # # GIT_PROMPT_SHOWUPSTREAM="verbose" # -# if [[ -z $__git_prompt_loaded__ && -# -f $ZSH/plugins/git-prompt/git-prompt.plugin.zsh ]]; -# then -# source $ZSH/plugins/git-prompt/git-prompt.plugin.zsh -# fi -# -# # # Some color settings for the format # # '_C' for color: # local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory @@ -426,7 +422,7 @@ __git_stash_state () # This is the short-circuit logic: local _big_repo='init' -TRAPINT() +__git_prompt_shortcircuit () { if [[ "$_big_repo" == 'yes' ]]; then _big_repo='' @@ -444,8 +440,13 @@ TRAPINT() $GIT_PROMPT_INFO_FUNC fi fi +} +TRAPINT () +{ + __git_prompt_shortcircuit return $(( 128 + $1 )) } + __git_dirty_state () { GIT_PROMPT_DIRTY_STATE_FRESH_REPO='' @@ -599,4 +600,3 @@ preexec_update_git_vars () } #-------------------------------------------------- -__git_prompt_loaded__='yes' diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index 3938ebe3c..d0c054a91 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -25,13 +25,12 @@ MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" #----------------------------------------------------- # git prompt info: +# $ZSH/lib/git-prompt.zsh will cause $GIT_PROMPT_INFO_FUNC to be called +# when the git prompt info needs to be updated. +GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO" + GIT_PROMPT_SHOWUPSTREAM="verbose" GIT_PROMPT_SHORTCIRCUIT='on' -GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO" -if [[ -z $__git_prompt_loaded__ && - -f $ZSH/plugins/git-prompt/git-prompt.plugin.zsh ]]; then - source $ZSH/plugins/git-prompt/git-prompt.plugin.zsh -fi # git_prompt_info colors ('_C' for color): local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory From c6cb7e6561edf6e1b73c4ca5d1c9f5aa6bd7a49d Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 19 May 2011 07:23:19 -0700 Subject: [PATCH 05/29] Fix git-prompt so that it properly renders the prompt info no matter what order it is loaded in regards to your theme file. --- lib/git-prompt.zsh | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/lib/git-prompt.zsh b/lib/git-prompt.zsh index aacc9cbff..5c1dc6b70 100644 --- a/lib/git-prompt.zsh +++ b/lib/git-prompt.zsh @@ -553,13 +553,14 @@ typeset -Uga chpwd_functions typeset -Uga periodic_functions # Append git functions needed for prompt. -preexec_functions+='preexec_update_git_vars' -precmd_functions+='precmd_update_git_vars' -chpwd_functions+="$GIT_PROMPT_INFO_FUNC" +preexec_functions+='__git_prompt_preexec_update_git_vars' +precmd_functions+='__git_prompt_precmd_update_git_vars' +chpwd_functions+="__git_prompt_info" PERIOD=15 -periodic_functions+="$GIT_PROMPT_INFO_FUNC" +periodic_functions+="__git_prompt_info" -precmd_update_git_vars() +__git_prompt_info () { $GIT_PROMPT_INFO_FUNC } +__git_prompt_precmd_update_git_vars() { if [[ $ZSH_VERSION = *\ 4.2* ]]; then # some older versions of zsh don't have periodic_functions, so do the @@ -571,31 +572,14 @@ precmd_update_git_vars() unset __EXECUTED_GIT_COMMAND fi } - -preexec_update_git_vars () +__git_prompt_preexec_update_git_vars () { case "$1" in - vim*) - __EXECUTED_GIT_COMMAND=1 - ;; - g*) - __EXECUTED_GIT_COMMAND=1 - ;; - rm*) - __EXECUTED_GIT_COMMAND=1 - ;; - touch*) - __EXECUTED_GIT_COMMAND=1 - ;; - mkdir*) - __EXECUTED_GIT_COMMAND=1 - ;; -# f) -# __EXECUTED_GIT_COMMAND=1 -# ;; -# fg) -# __EXECUTED_GIT_COMMAND=1 -# ;; + $EDITOR*) __EXECUTED_GIT_COMMAND=1 ;; + g*) __EXECUTED_GIT_COMMAND=1 ;; + rm*) __EXECUTED_GIT_COMMAND=1 ;; + touch*) __EXECUTED_GIT_COMMAND=1 ;; + mkdir*) __EXECUTED_GIT_COMMAND=1 ;; esac } From 656919e1387dcb5ebf3644f8ab0ba45a020c5883 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 19 May 2011 07:40:30 -0700 Subject: [PATCH 06/29] Move git-prompt from a lib to a plugin since I now have the load order immaterial. Update some of the names. --- .../git-prompt/git-prompt.plugin.zsh | 66 +++++++++---------- themes/ashleydev.zsh-theme | 17 +++-- 2 files changed, 43 insertions(+), 40 deletions(-) rename lib/git-prompt.zsh => plugins/git-prompt/git-prompt.plugin.zsh (92%) diff --git a/lib/git-prompt.zsh b/plugins/git-prompt/git-prompt.plugin.zsh similarity index 92% rename from lib/git-prompt.zsh rename to plugins/git-prompt/git-prompt.plugin.zsh index 5c1dc6b70..46abeded0 100644 --- a/lib/git-prompt.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -3,6 +3,9 @@ # This example shows some of the things you in this plugin. This is how the # author uses it: # +# NOTE: make sure to add 'git-prompt' to your list of oh-my-zsh plugins (in your +# .zshrc) otherwise the git prompt info will not show up in your prompt. +# # ---------------------- SAMPLE THEME FILE ------------------------ # # # this is a simple example PROMPT with only git info in it: @@ -65,25 +68,25 @@ # local __GIT_PROMPT_INFO='' # update__GIT_PROMPT_INFO () # { -# local g="$(__git_dir)" +# local g="$(_git_promt__git_dir)" # if [ -z "$g" ]; then # __GIT_PROMPT_INFO='' # return # fi # -# __git_stash_state +# _git_prompt__stash # local s=$GIT_PROMPT_STASH_STATE_DIRTY # -# __git_upstream +# _git_prompt__upstream # local p=$GIT_PROMPT_UPSTREAM_STATE # -# __git_branch +# _git_prompt__branch # local b=$GIT_PROMPT_BRANCH # -# __git_rebase_info +# _git_prompt__rebase_info # local r=$GIT_PROMPT_REBASE_INFO # -# __git_dirty_state +# _git_prompt__dirty_state # local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY # local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY # local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED @@ -146,19 +149,16 @@ #------------------ git information utils ------------------ -# To pull information out of git, I borrowed from: +# For some of the following functions, I borrowed some from: # https://github.com/git/git/blob/master/contrib/completion/git-completion.bash # - -# __git_dir accepts 0 or 1 arguments (i.e., location) +# _git_promt__git_dir accepts 0 or 1 arguments (i.e., location) # echos location of .git repo -__git_dir () +_git_promt__git_dir () { if [ -z "${1-}" ]; then - if [ -n "${__git_dir-}" ]; then - echo "$__git_dir" - elif [ -d .git ]; then + if [ -d .git ]; then echo .git else git rev-parse --git-dir 2>/dev/null @@ -186,17 +186,17 @@ __git_dir () # versions of git-rev-list # git always compare HEAD to @{upstream} # svn always compare HEAD to your SVN upstream -# By default, __git_upstream will compare HEAD to your SVN upstream +# By default, _git_prompt__upstream will compare HEAD to your SVN upstream # if it can find one, or @{upstream} otherwise. Once you have # set GIT_PROMPT_SHOWUPSTREAM, you can override it on a # per-repository basis by setting the prompt.showUpstream config # variable (i.e. `git config prompt.showUpstream 'verbose legacy'`). # -# __git_upstream accepts 0 or 1 arguments. If an argument is given, it must be -# a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM. Setting -# this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM or in -# the .git/config. -__git_upstream () +# _git_prompt__upstream accepts 0 or 1 arguments. If an argument is given, it +# must be a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM. +# Setting this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM +# or in the .git/config. +_git_prompt__upstream () { GIT_PROMPT_UPSTREAM_STATE='' @@ -298,7 +298,7 @@ __git_upstream () GIT_PROMPT_UPSTREAM_STATE=$p } -__git_rebase_info () +_git_prompt__rebase_info () { GIT_PROMPT_REBASE_INFO='' @@ -313,7 +313,7 @@ __git_rebase_info () fi local r="" - local g="$(__git_dir)" + local g="$(_git_promt__git_dir)" if [ -n "$g" ]; then if [ -f "$g/rebase-merge/interactive" ]; then r="|REBASE-i" @@ -342,7 +342,7 @@ __git_rebase_info () GIT_PROMPT_REBASE_INFO=$r } -__git_branch () +_git_prompt__branch () { GIT_PROMPT_BRANCH='' @@ -358,7 +358,7 @@ __git_branch () fi local b="" - local g="$(__git_dir)" + local g="$(_git_promt__git_dir)" if [ -n "$g" ]; then if [ -f "$g/rebase-merge/interactive" ]; then b="$(cat "$g/rebase-merge/head-name")" @@ -397,7 +397,7 @@ __git_branch () } -__git_stash_state () +_git_prompt__stash () { GIT_PROMPT_STASH_STATE_DIRTY='' @@ -447,7 +447,7 @@ TRAPINT () return $(( 128 + $1 )) } -__git_dirty_state () +_git_prompt__dirty_state () { GIT_PROMPT_DIRTY_STATE_FRESH_REPO='' GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='' @@ -466,7 +466,7 @@ __git_dirty_state () return fi - local g="$(__git_dir)" + local g="$(_git_promt__git_dir)" if [ -z "$g" ]; then return fi @@ -553,14 +553,14 @@ typeset -Uga chpwd_functions typeset -Uga periodic_functions # Append git functions needed for prompt. -preexec_functions+='__git_prompt_preexec_update_git_vars' -precmd_functions+='__git_prompt_precmd_update_git_vars' -chpwd_functions+="__git_prompt_info" +preexec_functions+='_git_prompt__preexec_update_git_vars' +precmd_functions+='_git_prompt__precmd_update_git_vars' +chpwd_functions+="_git_prompt_info" PERIOD=15 -periodic_functions+="__git_prompt_info" +periodic_functions+="_git_prompt_info" -__git_prompt_info () { $GIT_PROMPT_INFO_FUNC } -__git_prompt_precmd_update_git_vars() +_git_prompt_info () { $GIT_PROMPT_INFO_FUNC } +_git_prompt__precmd_update_git_vars() { if [[ $ZSH_VERSION = *\ 4.2* ]]; then # some older versions of zsh don't have periodic_functions, so do the @@ -572,7 +572,7 @@ __git_prompt_precmd_update_git_vars() unset __EXECUTED_GIT_COMMAND fi } -__git_prompt_preexec_update_git_vars () +_git_prompt__preexec_update_git_vars () { case "$1" in $EDITOR*) __EXECUTED_GIT_COMMAND=1 ;; diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index d0c054a91..992940b43 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -1,3 +1,6 @@ +# NOTE: make sure to add 'git-prompt' to your list of oh-my-zsh plugins (in your +# ~/.zshrc), otherwise the git prompt info will not be shown. +# #-------------------- PROMPT definition: ---------------------- # Set the prompt. @@ -25,7 +28,7 @@ MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" #----------------------------------------------------- # git prompt info: -# $ZSH/lib/git-prompt.zsh will cause $GIT_PROMPT_INFO_FUNC to be called +# The git-prompt plugin will cause $GIT_PROMPT_INFO_FUNC to be called # when the git prompt info needs to be updated. GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO" @@ -48,25 +51,25 @@ local __GIT_PROMPT_INFO='' # will set __GIT_PROMPT_INFO update__GIT_PROMPT_INFO () { - local g="$(__git_dir)" + local g="$(_git_promt__git_dir)" if [ -z "$g" ]; then __GIT_PROMPT_INFO='' return fi - __git_stash_state + _git_prompt__stash local s=$GIT_PROMPT_STASH_STATE_DIRTY - __git_upstream + _git_prompt__upstream local p=$GIT_PROMPT_UPSTREAM_STATE - __git_branch + _git_prompt__branch local b=$GIT_PROMPT_BRANCH - __git_rebase_info + _git_prompt__rebase_info local r=$GIT_PROMPT_REBASE_INFO - __git_dirty_state + _git_prompt__dirty_state local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED From cb300fb006c97300a80d00ede9c88a4baec3e2f6 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 19 May 2011 09:50:25 -0700 Subject: [PATCH 07/29] allow j and k to do (down|up)-line-or-search in vicmd mode --- plugins/vi-mode/vi-mode.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index aa39081f4..2263b8fdc 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -67,9 +67,11 @@ else fi bindkey "^P" up-line-or-search +bindkey -M vicmd "k" up-line-or-search bindkey -M vicmd "^k" up-line-or-search bindkey -M viins "^k" up-line-or-search bindkey "^N" down-line-or-search +bindkey -M vicmd "j" down-line-or-search bindkey -M vicmd "^j" down-line-or-search bindkey -M viins "^j" down-line-or-search From 1b3fa76a19bc67c37664398b91a40023ee287b75 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 19 May 2011 13:09:51 -0700 Subject: [PATCH 08/29] remove regex from git-prompt plugin because old zsh don't support regex --- plugins/git-prompt/git-prompt.plugin.zsh | 18 +++++++++--------- themes/ashleydev.zsh-theme | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 46abeded0..d01c5a9fd 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -498,41 +498,41 @@ _git_prompt__dirty_state () _big_repo='yes' local line while IFS=$'\n' read line; do - if [[ "$line" =~ '^M' ]]; then + if [[ "$line" = M* ]]; then GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='yes' GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' fi - if [[ "$line" =~ '^A' ]]; then + if [[ "$line" = A* ]]; then GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='yes' GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' fi - if [[ "$line" =~ '^R' ]]; then + if [[ "$line" = R* ]]; then GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='yes' GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' fi - if [[ "$line" =~ '^C' ]]; then + if [[ "$line" = C* ]]; then GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='yes' GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' fi - if [[ "$line" =~ '^D' ]]; then + if [[ "$line" = D* ]]; then GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='yes' GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' fi - if [[ "$line" =~ '^\?\? ' ]]; then + if [[ "$line" = \?\?* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes' GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' fi - if [[ "$line" =~ '^ M' ]]; then + if [[ "$line" = \ M* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes' GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' fi - if [[ "$line" =~ '^ D' ]]; then + if [[ "$line" = \ D* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='yes' GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' fi - if [[ "$line" =~ '^UU' ]]; then + if [[ "$line" = UU* ]]; then GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='yes' GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes' fi diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index 992940b43..d8d3a1594 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -115,7 +115,7 @@ update__GIT_PROMPT_INFO () local _prompt="$b$r$s$i$p" # add ( ) around _prompt: - if [ $f = 'yes' ]; then + if [ "$f" = 'yes' ]; then _prompt="($_prompt)" elif [ "$u" = "yes" ]; then _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" From 674327742b449572f873f9cdcf073da53e6bfeab Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Mon, 23 May 2011 16:49:29 -0700 Subject: [PATCH 09/29] Fix up some bugs that showed up when using zsh < 4.3 --- plugins/git/git.plugin.zsh | 8 ++++---- plugins/vi-mode/vi-mode.plugin.zsh | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index fdcaf0e61..859b637c6 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -40,7 +40,7 @@ alias ghhhh="git log --graph --stat -p --full-diff $pretty_format_medium"; compd # Git and svn mix alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' -compdef git-svn-dcommit-push=git +compdef _git git-svn-dcommit-push=git # # Will return the current branch name @@ -53,8 +53,8 @@ function current_branch() { # these aliases take advantage of the previous function alias ggpull='git pull origin $(current_branch)' -compdef ggpull=git +compdef _git ggpull=git alias ggpush='git push origin $(current_branch)' -compdef ggpush=git +compdef _git ggpush=git alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' -compdef ggpnp=git +compdef _git ggpnp=git diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh index 2263b8fdc..04229b7a1 100644 --- a/plugins/vi-mode/vi-mode.plugin.zsh +++ b/plugins/vi-mode/vi-mode.plugin.zsh @@ -14,10 +14,6 @@ if [[ "$MODE_INDICATOR" == "" ]]; then MODE_INDICATOR="%{$fg_bold[red]%}<%{$reset_color%}%{$fg[red]%}<<%{$reset_color%}" fi -function zle-line-init zle-keymap-select { - zle reset-prompt -} - # If I am using vi keys, I want to know what mode I'm currently using. # zle-keymap-select is executed every time KEYMAP changes. # From http://zshwiki.org/home/examples/zlewidgets From 1816e957770f8e3f0ad22658f741c5f0492da982 Mon Sep 17 00:00:00 2001 From: alanpeabody Date: Thu, 26 May 2011 23:56:45 -0400 Subject: [PATCH 10/29] Added my own theme. --- themes/alanpeabody.zsh-theme | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 themes/alanpeabody.zsh-theme diff --git a/themes/alanpeabody.zsh-theme b/themes/alanpeabody.zsh-theme new file mode 100644 index 000000000..1f66f1ec3 --- /dev/null +++ b/themes/alanpeabody.zsh-theme @@ -0,0 +1,22 @@ + +local user='%{$fg[magenta]%}%n@%{$fg[magenta]%}%m%{$reset_color%}' +local pwd='%{$fg[blue]%}%~%{$reset_color%}' +local rvm='%{$fg[green]%}‹$(rvm-prompt i v g)›%{$reset_color%}' +local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})' +local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}' + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚" +ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖" +ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭" + +PROMPT="${user} ${pwd}$ " +RPROMPT="${return_code} ${git_branch} ${rvm}" + From 1c2eb40e876db3d2bfad22a0b52f0d410e1d51f3 Mon Sep 17 00:00:00 2001 From: nebirhos Date: Thu, 26 May 2011 20:00:23 +0200 Subject: [PATCH 11/29] Added nebirhos theme --- themes/nebirhos.zsh-theme | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 themes/nebirhos.zsh-theme diff --git a/themes/nebirhos.zsh-theme b/themes/nebirhos.zsh-theme new file mode 100644 index 000000000..c49df972e --- /dev/null +++ b/themes/nebirhos.zsh-theme @@ -0,0 +1,17 @@ +# Based on robbyrussell's theme, with host and rvm indicators. Example: +# @host ➜ currentdir rvm:(rubyversion@gemset) git:(branchname) + +# Get the current ruby version in use with RVM: +if [ -e ~/.rvm/bin/rvm-prompt ]; then + RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%})%{$reset_color%} " +fi + +# Get the host name (first 4 chars) +HOST_PROMPT_="%{$fg_bold[red]%}@$HOST[0,4] ➜ %{$fg_bold[cyan]%}%c " +GIT_PROMPT="%{$fg_bold[blue]%}\$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}" +PROMPT="$HOST_PROMPT_$RUBY_PROMPT_$GIT_PROMPT" + +ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" From 1e3b441ce7e0b8706867801c1e5e7ca6760ff17e Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Mon, 30 May 2011 10:07:15 -0400 Subject: [PATCH 12/29] Rollback of Pull #366 sorin-ionescu had some good points. --- plugins/brew/brew.plugin.zsh | 12 ------------ plugins/node/node.plugin.zsh | 5 +---- plugins/npm/npm.plugin.zsh | 2 -- plugins/rvm/rvm.plugin.zsh | 9 ++------- 4 files changed, 3 insertions(+), 25 deletions(-) delete mode 100644 plugins/npm/npm.plugin.zsh diff --git a/plugins/brew/brew.plugin.zsh b/plugins/brew/brew.plugin.zsh index f584a4684..c2e95884e 100644 --- a/plugins/brew/brew.plugin.zsh +++ b/plugins/brew/brew.plugin.zsh @@ -1,13 +1 @@ -# Move /usr/local/bin (path where brews are linked) to the front of the path -# This will allow us to override system binaries like ruby with our brews -# TODO: Do this in a more compatible way. -# What if someone doesn't have /usr/bin in their path? -export PATH=`echo $PATH | sed -e 's|/usr/local/bin||' -e 's|::|:|g'` # Remove /usr/local/bin -export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/bin:&|'` # Add it in front of /usr/bin -export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/sbin:&|'` # Add /usr/local/sbin - alias brews='brew list -1' - -function brew-link-completion { - ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" "$ZSH/plugins/brew/_brew.official" -} diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh index 18f35333c..519bc18da 100644 --- a/plugins/node/node.plugin.zsh +++ b/plugins/node/node.plugin.zsh @@ -1,8 +1,5 @@ -# This works if you installed node via homebrew. -export NODE_PATH="/usr/local/lib/node" - # Open the node api for your current version to the optional section. # TODO: Make the section part easier to use. -function node-api { +function node-docs { open "http://nodejs.org/docs/$(node --version)/api/all.html#$1" } diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh deleted file mode 100644 index 0b0a30e11..000000000 --- a/plugins/npm/npm.plugin.zsh +++ /dev/null @@ -1,2 +0,0 @@ -# TODO: Don't do this in such a weird way. -export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/share/npm/bin:&|'` diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 8a3ec788a..40fd88c1a 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -1,6 +1,5 @@ -fpath=($ZSH/plugins/rvm $fpath) -autoload -U compinit -compinit -i +# What does this really do? +# fpath=($ZSH/plugins/rvm $fpath) alias rubies='rvm list rubies' alias gemsets='rvm gemset list' @@ -35,10 +34,6 @@ function rvm-update { rvm reload # TODO: Reload rvm completion? } -function rvm-link-completion { - ln -s "$rvm_path/scripts/zsh/Completion/_rvm" "$ZSH/plugins/rvm/_rvm.official" -} - # TODO: Make this usable w/o rvm. function gems { local current_ruby=`rvm-prompt i v p` From 9801ad6453caa05925847f63401e6266378eb2de Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Mon, 30 May 2011 11:10:08 -0400 Subject: [PATCH 13/29] Remove Uneeded Lines --- plugins/rvm/rvm.plugin.zsh | 3 --- 1 file changed, 3 deletions(-) diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 40fd88c1a..24621fe0b 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -1,6 +1,3 @@ -# What does this really do? -# fpath=($ZSH/plugins/rvm $fpath) - alias rubies='rvm list rubies' alias gemsets='rvm gemset list' From 93dab36fcb7f138aba32e5102c621180055d67fe Mon Sep 17 00:00:00 2001 From: Second Planet Date: Mon, 30 May 2011 19:10:26 -0400 Subject: [PATCH 14/29] added humza.zsh-theme --- themes/humza.zsh-theme | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 themes/humza.zsh-theme diff --git a/themes/humza.zsh-theme b/themes/humza.zsh-theme new file mode 100644 index 000000000..107886295 --- /dev/null +++ b/themes/humza.zsh-theme @@ -0,0 +1,26 @@ +# ZSH THEME Preview: https://skitch.com/huyy/rk979/humza.zshtheme + +let TotalBytes=0 +for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }') +do + let TotalBytes=$TotalBytes+$Bytes +done + # should it say b, kb, Mb, or Gb +if [ $TotalBytes -lt 1024 ]; then + TotalSize=$(echo -e "scale=3 \n$TotalBytes \nquit" | bc) + suffix="b" +elif [ $TotalBytes -lt 1048576 ]; then + TotalSize=$(echo -e "scale=3 \n$TotalBytes/1024 \nquit" | bc) + suffix="kb" +elif [ $TotalBytes -lt 1073741824 ]; then + TotalSize=$(echo -e "scale=3 \n$TotalBytes/1048576 \nquit" | bc) + suffix="Mb" +else + TotalSize=$(echo -e "scale=3 \n$TotalBytes/1073741824 \nquit" | bc) + suffix="Gb" +fi + +PROMPT='%{$reset_color%}%n %{$fg[green]%}{%{$reset_color%}%~%{$fg[green]%}}%{$reset_color%}$(git_prompt_info) greetings, earthling %{$fg[green]%}[%{$reset_color%}%{$TotalSize%}%{$suffix%}%{$fg[green]%}]%{$fg[red]%}$%{$reset_color%} ☞ ' + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}±(" +ZSH_THEME_GIT_PROMPT_SUFFIX=");%{$reset_color%}" From f4878971752b6d76743c29d6f478d20c84755b8e Mon Sep 17 00:00:00 2001 From: Brian Riddle Date: Tue, 31 May 2011 14:16:43 +0200 Subject: [PATCH 15/29] fix double -f and corrected format. -f%m was getting called twice in the stat_cmd corrected format of stat command from y to Y. --- plugins/ant/ant.plugin.zsh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/ant/ant.plugin.zsh b/plugins/ant/ant.plugin.zsh index 23bc7756a..691d4d2db 100644 --- a/plugins/ant/ant.plugin.zsh +++ b/plugins/ant/ant.plugin.zsh @@ -2,14 +2,14 @@ stat -f%m . > /dev/null 2>&1 if [ "$?" = 0 ]; then stat_cmd=(stat -f%m) else - stat_cmd=(stat -L --format=%y) + stat_cmd=(stat -L --format=%Y) fi _ant_does_target_list_need_generating () { if [ ! -f .ant_targets ]; then return 0; else - accurate=$($stat_cmd -f%m .ant_targets) - changed=$($stat_cmd -f%m build.xml) + accurate=$($stat_cmd .ant_targets) + changed=$($stat_cmd build.xml) return $(expr $accurate '>=' $changed) fi } From c014dca141588737a13c4e3974adb4afd58c09bb Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Tue, 31 May 2011 15:13:23 -0700 Subject: [PATCH 16/29] Fix deleted in git.zsh --- lib/git.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/git.zsh b/lib/git.zsh index 2ace3d0e0..ce4de5598 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -52,11 +52,11 @@ git_prompt_status() { if $(echo "$INDEX" | grep '^R ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" fi - if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then + if $(echo "$INDEX" | grep '^D ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" fi echo $STATUS -} \ No newline at end of file +} From 23a082df129b12b6edf8ea04432b0cb2be0588fd Mon Sep 17 00:00:00 2001 From: Robby Russell Date: Wed, 1 Jun 2011 09:33:12 +0200 Subject: [PATCH 17/29] Revert "Added my zsh theme file, heavily based on sjl's" as it relies on a dotfile to be in ~/bin. This reverts commit f2f34f5404e8ab674a0e345a709783b6c56a3b72. --- themes/thomasjbradley.zsh-theme | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 themes/thomasjbradley.zsh-theme diff --git a/themes/thomasjbradley.zsh-theme b/themes/thomasjbradley.zsh-theme deleted file mode 100644 index 857301d19..000000000 --- a/themes/thomasjbradley.zsh-theme +++ /dev/null @@ -1,29 +0,0 @@ -function prompt_char { - git branch >/dev/null 2>/dev/null && echo '±' && return - hg root >/dev/null 2>/dev/null && echo '☿' && return - echo '○' -} - -function virtualenv_info { - [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') ' -} - -function hg_prompt_info { - hg prompt --angle-brackets "\ -< on %{$fg[magenta]%}%{$reset_color%}>\ -< at %{$fg[yellow]%}%{$reset_color%}>\ -%{$fg[green]%}%{$reset_color%}< -patches: >" 2>/dev/null -} - -PROMPT=' -%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info) -$(virtualenv_info)$(prompt_char) ' - -ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?" -ZSH_THEME_GIT_PROMPT_CLEAN="" - -. ~/bin/dotfiles/zsh/aliases From 0d476e02cd1b5660b09acde25725191044f062ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Had=C5=BEi=C4=87?= Date: Wed, 1 Jun 2011 12:45:15 +0200 Subject: [PATCH 18/29] Adds my theme --- themes/miloshadzic.zsh-theme | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 themes/miloshadzic.zsh-theme diff --git a/themes/miloshadzic.zsh-theme b/themes/miloshadzic.zsh-theme new file mode 100644 index 000000000..ad5394423 --- /dev/null +++ b/themes/miloshadzic.zsh-theme @@ -0,0 +1,8 @@ +# Yay! High voltage and arrows! + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " +ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +PROMPT='%{$fg[cyan]%}%1~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}$(git_prompt_info)%{$fg[cyan]%}⇒%{$reset_color%} ' From c1b5d72830629c737f40abebf87fcca797bf730c Mon Sep 17 00:00:00 2001 From: "Suraj N. Kurapati" Date: Wed, 1 Jun 2011 20:38:25 -0700 Subject: [PATCH 19/29] add "sunaku" theme, see http://ompldr.org/vOHcwZg --- themes/sunaku.zsh-theme | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 themes/sunaku.zsh-theme diff --git a/themes/sunaku.zsh-theme b/themes/sunaku.zsh-theme new file mode 100644 index 000000000..440fa90b4 --- /dev/null +++ b/themes/sunaku.zsh-theme @@ -0,0 +1,26 @@ +# Git-centric variation of the "fishy" theme. +# See screenshot at http://ompldr.org/vOHcwZg + +ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}+" +ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[magenta]%}!" +ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}-" +ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}>" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}#" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[yellow]%}?" + +ZSH_THEME_GIT_PROMPT_PREFIX="" +ZSH_THEME_GIT_PROMPT_SUFFIX=" " +ZSH_THEME_GIT_PROMPT_DIRTY="" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +local user_color='green' +test $UID -eq 0 && user_color='red' + +PROMPT='%(?..%{$fg_bold[red]%}exit %? +%{$reset_color%})'\ +'%{$bold_color%}$(git_prompt_status)%{$reset_color%}'\ +'$(git_prompt_info)'\ +'%{$fg[$user_color]%}%~%{$reset_color%}'\ +'%(!.#.>) ' + +PROMPT2='%{$fg[red]%}\ %{$reset_color%}' From d40d2cb78d4c79671b912e9845972ce2cea9ba79 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 2 Jun 2011 10:19:10 -0700 Subject: [PATCH 20/29] updates and cleanups to git prompt stuff --- plugins/git-prompt/git-prompt.plugin.zsh | 67 +++++++++--------- themes/ashleydev.zsh-theme | 88 ++++++++++++++---------- 2 files changed, 88 insertions(+), 67 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 46abeded0..23747d26a 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -3,14 +3,14 @@ # This example shows some of the things you in this plugin. This is how the # author uses it: # -# NOTE: make sure to add 'git-prompt' to your list of oh-my-zsh plugins (in your -# .zshrc) otherwise the git prompt info will not show up in your prompt. +# NOTE: make sure to add 'git' to your list of oh-my-zsh plugins (in your +# .zshrc) otherwise this git prompt info will not show up in your prompt. # # ---------------------- SAMPLE THEME FILE ------------------------ # -# # this is a simple example PROMPT with only git info in it: +# # this is a simple example PROMPT with only git +# # info from this plugin in it: # PROMPT='$__GIT_PROMPT_INFO# ' -# # # # Set GIT_PROMPT_SHORTCIRCUIT='off' to turn the # # short-circuit logic off. The short-circuit @@ -19,9 +19,9 @@ # # while the prompt is updating the dirty state # # info. Gathering dirty-state info can take a # # long time on large repositories, so if you -# # find that you're prompt is taking for ever to -# # show up, and you press ctrl-c, the short- -# # circuit logic will turn of the showing of +# # find that your prompt is taking for ever to +# # return, and you press ctrl-c, the short- +# # circuit logic will turn off the showing of # # dirty state for this repository (locally) and # # let you know, that way you won't be slowed # # down waiting for your prompt in large git @@ -30,38 +30,41 @@ # # # GIT_PROMPT_INFO_FUNC must be set to the # # function that defines your prompt info -# # in order to turn the git-prompt plugin on. -# # $ZSH/lib/git-prompt.zsh will cause +# # in order to turn this plugin on. # # $GIT_PROMPT_INFO_FUNC to be called when the -# # git prompt info needs to be updated. +# # git prompt info variable needs to be updated. # GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO' # # GIT_PROMPT_SHOWUPSTREAM="verbose" # -# # Some color settings for the format +# # Some color settings for my prompt format # # '_C' for color: -# local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory -# local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo -# local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean -# local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty -# local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info -# local _Ci_="%{$bold_color$fg[red]%}" # index info -# local _Cu_clean_="" # untracked files state when clean -# local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty -# local _Cp_="%{${fg[cyan]}%}" # upstream info -# local _Cs_="" # stash state -# # 'R'eset formating -# local R="%{$terminfo[sgr0]%}" +# if [[ "$DISABLE_COLOR" != "true" ]]; then +# local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory +# local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo +# local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean +# local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty +# local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info +# local _Ci_="%{$bold_color$fg[red]%}" # index info +# local _Cu_clean_="" # untracked files state when clean +# local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty +# local _Cp_="%{${fg[cyan]}%}" # upstream info +# local _Cs_="" # stash state +# # 'R'eset formating +# local R="%{$terminfo[sgr0]%}" +# fi # # # This function creates the format and content -# # of the git prompt info. It shows some of the -# # ways you can set up your prompt with this -# # plugin. +# # of the git prompt info and puts the result +# # in $__GIT_PROMPT_INFO. Which you can use in +# # your $PROMPT (see above). This is an +# # example of some of the ways you can set up +# # your prompt with this plugin. # # -# # This function must set a global variable (with -# # the your git prompt format) that you include in -# # your PROMPT string. -# # NOTE: it cannot echo this info as in: +# # NOTE: This function must set a global variable +# # (with the your git prompt format) that you +# # include in your PROMPT string. +# # It cannot echo this info as in: # # PROMPT="$(update__GIT_PROMPT_INFO)" # # or the short-circuit logic will not work. # # @@ -69,6 +72,7 @@ # update__GIT_PROMPT_INFO () # { # local g="$(_git_promt__git_dir)" +# # short circuit if we're not in a git repo: # if [ -z "$g" ]; then # __GIT_PROMPT_INFO='' # return @@ -154,7 +158,8 @@ # # _git_promt__git_dir accepts 0 or 1 arguments (i.e., location) -# echos location of .git repo +# echos the location of .git repo. +# Useful for quickly figuring out if cwd is under a git repo. _git_promt__git_dir () { if [ -z "${1-}" ]; then diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index 992940b43..68fa48d14 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -1,52 +1,48 @@ -# NOTE: make sure to add 'git-prompt' to your list of oh-my-zsh plugins (in your +# NOTE: make sure to add 'git' to your list of oh-my-zsh plugins (in your # ~/.zshrc), otherwise the git prompt info will not be shown. -# -#-------------------- PROMPT definition: ---------------------- -# Set the prompt. -# Reset formating -local R="%{$terminfo[sgr0]%}" +#-------------------- Colors ---------------------- +# Colors ('_C' for color): +if [[ "$DISABLE_COLOR" != "true" ]]; then + # git prompt info colors: + local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory + local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo + local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean + local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty + local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info + local _Ci_="%{$bold_color$fg[red]%}" # index info + local _Cu_clean_="" # untracked files state when clean + local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty + local _Cp_="%{${fg[cyan]}%}" # upstream info + local _Cs_="" # stash state -# special colors for privileged users (root) -local user_="%(!.%{$fg_bold[yellow]$bg[red]%}.%{$fg_bold[cyan]%})%n$R" -local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m$R" -local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~$R" -local jobs_="%(1j.%{$fg[blue]%}%j$R.)" + # Reset formating: + local R="%{$terminfo[sgr0]%}" -PROMPT='$user_$host_$path_ $__GIT_PROMPT_INFO$jobs_# ' + # PROMPT colors: + local _Cuser_root_="%{$fg_bold[yellow]$bg[red]%}" + local _Chost_root_="%{$fg[red]%}" + local _Cpath_root_="%{$fg_bold[white]%}" + local _Cuser_="%{$fg_bold[cyan]%}" + local _Chost_="%{$fg_bold[blue]%}" + local _Cpath_="%{$fg_bold[white]%}" + local _Cjobs_="%{$fg[blue]%}" -local date_format_="%D{%a %b %d}, %*" -local date_="%{$fg[green]%}[$date_format_]" -local return_code_="%(?..%{$fg[red]%}%? ↵ )" + # RPROMPT colors: + local _Cdate_="%{$fg[green]%}" + local _Creturn_code_="%{$fg[red]%}" + local _Cvi_mode_="%{$fg_bold[cyan]%}" +fi -RPROMPT='$return_code_$R$date_$R' - -# use the vi-mode oh-my-zsh plugin to get this: -MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R" - -# #----------------------------------------------------- # git prompt info: -# The git-prompt plugin will cause $GIT_PROMPT_INFO_FUNC to be called -# when the git prompt info needs to be updated. +# The git prompt plugin will cause $GIT_PROMPT_INFO_FUNC to be called +# when $__GIT_PROMPT_INFO needs to be updated. GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO" - GIT_PROMPT_SHOWUPSTREAM="verbose" GIT_PROMPT_SHORTCIRCUIT='on' -# git_prompt_info colors ('_C' for color): -local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory -local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo -local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean -local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty -local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info -local _Ci_="%{$bold_color$fg[red]%}" # index info -local _Cu_clean_="" # untracked files state when clean -local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty -local _Cp_="%{${fg[cyan]}%}" # upstream info -local _Cs_="" # stash state - local __GIT_PROMPT_INFO='' # will set __GIT_PROMPT_INFO update__GIT_PROMPT_INFO () @@ -126,3 +122,23 @@ update__GIT_PROMPT_INFO () __GIT_PROMPT_INFO="$R$_prompt$R" } + + +#-------------------- PROMPT definition: ---------------------- +# +local user_="%(!.$_Cuser_root_.$_Cuser_)%n$R" +local host_="%(!.$_Chost_root_.$_Chost_)%m$R" +local path_="%(!.$_Cpath_root_.$_Cpath_)%~$R" +local jobs_="%(1j.$_Cjobs_%j$R.)" + +PROMPT='$user_$host_$path_ $__GIT_PROMPT_INFO$jobs_# ' + +local date_format_='%D{%a %b %d}, %*' +local date_="${_Cdate_}[$date_format_]$R" +local return_code_="%(?..$_Creturn_code_%? ↵ )$R" + +RPROMPT='$return_code_$date_' + +# use the vi-mode oh-my-zsh plugin to get this: +MODE_INDICATOR="${_Cvi_mode_}-- CMD MODE -- $R" + From d1088b286006b7fe71623eee68dc7965b38364ef Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 2 Jun 2011 10:35:22 -0700 Subject: [PATCH 21/29] add file header, and better comments and info about options that are available in the sample. --- plugins/git-prompt/git-prompt.plugin.zsh | 46 +++++++++++++++--------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git-prompt/git-prompt.plugin.zsh index 8a17acb3f..1152f5d4b 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git-prompt/git-prompt.plugin.zsh @@ -1,11 +1,18 @@ +# ------------------------------------------------------------------------------ +# FILE: git-prompt.plugin.zsh +# DESCRIPTION: oh-my-zsh git information for your PROMPT. +# AUTHOR: Ashley Dev (the.ashley.dev+git-prompt@gmail.com) +# VERSION: 2.1 +# SCREENSHOT: +# ------------------------------------------------------------------------------ + # USAGE: # -# This example shows some of the things you in this plugin. This is how the -# author uses it: -# -# NOTE: make sure to add 'git' to your list of oh-my-zsh plugins (in your -# .zshrc) otherwise this git prompt info will not show up in your prompt. +# Add 'git' to your list of oh-my-zsh plugins (in your .zshrc) otherwise this +# git prompt info will not show up in your prompt. # +# This example shows some of the things you can do with this plugin. This is +# how the author uses it: # ---------------------- SAMPLE THEME FILE ------------------------ # # # this is a simple example PROMPT with only git @@ -26,16 +33,14 @@ # # let you know, that way you won't be slowed # # down waiting for your prompt in large git # # repositories. -# GIT_PROMPT_SHORTCIRCUIT='on' +# #GIT_PROMPT_SHORTCIRCUIT='off' # -# # GIT_PROMPT_INFO_FUNC must be set to the -# # function that defines your prompt info -# # in order to turn this plugin on. -# # $GIT_PROMPT_INFO_FUNC to be called when the -# # git prompt info variable needs to be updated. -# GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO' -# # GIT_PROMPT_SHOWUPSTREAM="verbose" +# #GIT_PROMPT_SHOWREBASEINFO='off' +# #GIT_PROMPT_SHOWBRANCH='off' +# #GIT_PROMPT_SHOWSTASHSTATE='off' +# #GIT_PROMPT_SHORTCIRCUIT='off' +# #GIT_PROMPT_SHOWDIRTYSTATE='off' # # # Some color settings for my prompt format # # '_C' for color: @@ -54,10 +59,17 @@ # local R="%{$terminfo[sgr0]%}" # fi # -# # This function creates the format and content -# # of the git prompt info and puts the result -# # in $__GIT_PROMPT_INFO. Which you can use in -# # your $PROMPT (see above). This is an +# # GIT_PROMPT_INFO_FUNC must be set to the +# # function that defines your prompt info +# # in order to turn this plugin on. +# # $GIT_PROMPT_INFO_FUNC to be called when the +# # git prompt info variable needs to be updated. +# GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO' +# +# # update__GIT_PROMPT_INFO creates the format and +# # content of the git prompt info and puts the +# # result in $__GIT_PROMPT_INFO. Which you can +# # use in your $PROMPT (see above). This is an # # example of some of the ways you can set up # # your prompt with this plugin. # # From fcbca579aef7846e0401a2ca27984178f7f50dc1 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 2 Jun 2011 11:22:39 -0700 Subject: [PATCH 22/29] Update plugins/git: - move aliases into plugins/git/git-aliases.plugin.zsh - move git prompt info into plugins/git/git-prompt-old.plugin.zsh - add revamped git prompt info into plugins/git/git-prompt.plugin.zsh - plugins/git/git.plugin.zsh now just sources the above files Added themes/ashleydev.theme.zsh that takes advantage of the new git prompt info --- plugins/git/git-aliases.plugin.zsh | 60 ++++++++++++++++++ .../git/git-prompt-old.plugin.zsh | 42 +++++++++---- .../{git-prompt => git}/git-prompt.plugin.zsh | 5 +- plugins/git/git.plugin.zsh | 63 +------------------ themes/ashleydev.zsh-theme | 2 +- 5 files changed, 96 insertions(+), 76 deletions(-) create mode 100644 plugins/git/git-aliases.plugin.zsh rename lib/git.zsh => plugins/git/git-prompt-old.plugin.zsh (56%) rename plugins/{git-prompt => git}/git-prompt.plugin.zsh (99%) diff --git a/plugins/git/git-aliases.plugin.zsh b/plugins/git/git-aliases.plugin.zsh new file mode 100644 index 000000000..859b637c6 --- /dev/null +++ b/plugins/git/git-aliases.plugin.zsh @@ -0,0 +1,60 @@ +# Aliases +alias g='git' ; compdef g=git +alias ga='git add' ; compdef _git ga=git-add +alias gaa='git add --all' ; compdef _git gaa=git-add +alias gs='git status' ; compdef _git gs=git-status +alias gst='git status' ; compdef _git gst=git-status +# for `gsts ""` +alias gsts='git stash save' ; compdef _git gsts=git-stash +alias gstp='git stash pop' ; compdef _git gstp=git-stash +alias gstl='git stash list' ; compdef _git gstl=git-stash +alias gstll='git stash show -p --stat' ; compdef _git gstll=git-stash +alias gl='git pull' ; compdef _git gl=git-pull +alias gup='git fetch && git rebase' ; compdef _git gup=git-fetch +alias gf='git fetch' ; compdef _git gf=git-fetch +alias gp='git push' ; compdef _git gp=git-push +alias gd='git diff --no-ext-diff -b' ; compdef _git gd=git-diff +alias gdd='git diff --no-ext-diff' ; compdef _git gdd=git-diff +gdv() { git-diff -w "$@" | view - } ; compdef _git gdv=git-diff +alias gc='git commit -v' ; compdef _git gc=git-commit +alias gca='git commit -v -a' ; compdef _git gca=git-commit +alias gco='git checkout' ; compdef _git gco=git-checkout +alias gb='git branch' ; compdef _git gb=git-branch +alias gba='git branch -a' ; compdef _git gba=git-branch +alias gcount='git shortlog -sn' ; compdef gcount=git +alias gcp='git cherry-pick' ; compdef _git gcp=git-cherry-pick +alias gm='git merge' ; compdef _git gm=git-merge +alias glg='git log --stat --max-count=5'; compdef _git glg=git-log + +# Git history (pretty) +local pretty_format_oneline='--pretty=format:"%C(yellow)%h %C(green)%cd %C(cyan)%an %C(bold cyan)%d%C(reset) %s" --date=short' +local pretty_format_medium='--pretty=format:"%C(yellow)commit %H %C(bold cyan)%d%C(reset) +%C(cyan)Author: %an <%ae>%C(reset) +%C(green)Date: %cd%C(reset) +%+s +%+b"' +alias gh="git log --graph $pretty_format_oneline" ; compdef _git gh=git-log +alias ghh="git log --graph $pretty_format_medium" ; compdef _git gh=git-log +alias ghhh="git log --graph --stat $pretty_format_medium" ; compdef _git gh=git-log +alias ghhhh="git log --graph --stat -p --full-diff $pretty_format_medium"; compdef _git gh=git-log + +# Git and svn mix +alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' +compdef _git git-svn-dcommit-push=git + +# +# Will return the current branch name +# Usage example: git pull origin $(current_branch) +# +function current_branch() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + echo ${ref#refs/heads/} +} + +# these aliases take advantage of the previous function +alias ggpull='git pull origin $(current_branch)' +compdef _git ggpull=git +alias ggpush='git push origin $(current_branch)' +compdef _git ggpush=git +alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' +compdef _git ggpnp=git diff --git a/lib/git.zsh b/plugins/git/git-prompt-old.plugin.zsh similarity index 56% rename from lib/git.zsh rename to plugins/git/git-prompt-old.plugin.zsh index 235f9de12..ece86e6d3 100644 --- a/lib/git.zsh +++ b/plugins/git/git-prompt-old.plugin.zsh @@ -1,11 +1,21 @@ -# get the name of the branch we are on +# Renders the name of the current branch. function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + local branch=$(git_current_branch) + if [[ -n "$branch" ]]; then + echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}" + fi } -# Checks if working tree is dirty -parse_git_dirty() { +# Gets the current branch. +function git_current_branch() { + local ref=$(git symbolic-ref HEAD 2> /dev/null) + if [[ -n "$ref" ]]; then + echo "${ref#refs/heads/}" + fi +} + +# Checks if the working tree is dirty. +function parse_git_dirty() { if [[ -n $(git status -s 2> /dev/null) ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" else @@ -13,25 +23,31 @@ parse_git_dirty() { fi } -# Checks if there are commits ahead from remote +# Checks if there are commits ahead from remote. function git_prompt_ahead() { - if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } -# Formats prompt string for current git commit short SHA +# Formats the prompt string for current git commit short SHA. function git_prompt_short_sha() { - SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + local sha=$(git rev-parse --short HEAD 2> /dev/null) + if [[ -n "$sha" ]]; then + echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}" + fi } -# Formats prompt string for current git commit long SHA +# Formats the prompt string for current git commit long SHA. function git_prompt_long_sha() { - SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + local sha=$(git rev-parse HEAD 2> /dev/null) + if [[ -n "$sha" ]]; then + echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}" + fi } -# Get the status of the working tree -git_prompt_status() { +# Gets the status of the working tree. +function git_prompt_status() { local indicators line untracked added modified renamed deleted while IFS=$'\n' read line; do if [[ "$line" =~ '^\?\? ' ]]; then diff --git a/plugins/git-prompt/git-prompt.plugin.zsh b/plugins/git/git-prompt.plugin.zsh similarity index 99% rename from plugins/git-prompt/git-prompt.plugin.zsh rename to plugins/git/git-prompt.plugin.zsh index 1152f5d4b..5b575be6c 100644 --- a/plugins/git-prompt/git-prompt.plugin.zsh +++ b/plugins/git/git-prompt.plugin.zsh @@ -146,7 +146,7 @@ # r="$_Cr_$r$R" # fi # -# local _prompt="$b$r$s$i$p" +# local _prompt="$b$r$i$s$p" # # add ( ) around _prompt: # if [ $f = 'yes' ]; then # _prompt="($_prompt)" @@ -538,7 +538,6 @@ _git_prompt__dirty_state () if [[ "$line" = \?\?* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes' - GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' fi if [[ "$line" = \ M* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes' @@ -577,6 +576,8 @@ PERIOD=15 periodic_functions+="_git_prompt_info" _git_prompt_info () { $GIT_PROMPT_INFO_FUNC } +_git_prompt_info + _git_prompt__precmd_update_git_vars() { if [[ $ZSH_VERSION = *\ 4.2* ]]; then diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 859b637c6..bb515c73a 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -1,60 +1,3 @@ -# Aliases -alias g='git' ; compdef g=git -alias ga='git add' ; compdef _git ga=git-add -alias gaa='git add --all' ; compdef _git gaa=git-add -alias gs='git status' ; compdef _git gs=git-status -alias gst='git status' ; compdef _git gst=git-status -# for `gsts ""` -alias gsts='git stash save' ; compdef _git gsts=git-stash -alias gstp='git stash pop' ; compdef _git gstp=git-stash -alias gstl='git stash list' ; compdef _git gstl=git-stash -alias gstll='git stash show -p --stat' ; compdef _git gstll=git-stash -alias gl='git pull' ; compdef _git gl=git-pull -alias gup='git fetch && git rebase' ; compdef _git gup=git-fetch -alias gf='git fetch' ; compdef _git gf=git-fetch -alias gp='git push' ; compdef _git gp=git-push -alias gd='git diff --no-ext-diff -b' ; compdef _git gd=git-diff -alias gdd='git diff --no-ext-diff' ; compdef _git gdd=git-diff -gdv() { git-diff -w "$@" | view - } ; compdef _git gdv=git-diff -alias gc='git commit -v' ; compdef _git gc=git-commit -alias gca='git commit -v -a' ; compdef _git gca=git-commit -alias gco='git checkout' ; compdef _git gco=git-checkout -alias gb='git branch' ; compdef _git gb=git-branch -alias gba='git branch -a' ; compdef _git gba=git-branch -alias gcount='git shortlog -sn' ; compdef gcount=git -alias gcp='git cherry-pick' ; compdef _git gcp=git-cherry-pick -alias gm='git merge' ; compdef _git gm=git-merge -alias glg='git log --stat --max-count=5'; compdef _git glg=git-log - -# Git history (pretty) -local pretty_format_oneline='--pretty=format:"%C(yellow)%h %C(green)%cd %C(cyan)%an %C(bold cyan)%d%C(reset) %s" --date=short' -local pretty_format_medium='--pretty=format:"%C(yellow)commit %H %C(bold cyan)%d%C(reset) -%C(cyan)Author: %an <%ae>%C(reset) -%C(green)Date: %cd%C(reset) -%+s -%+b"' -alias gh="git log --graph $pretty_format_oneline" ; compdef _git gh=git-log -alias ghh="git log --graph $pretty_format_medium" ; compdef _git gh=git-log -alias ghhh="git log --graph --stat $pretty_format_medium" ; compdef _git gh=git-log -alias ghhhh="git log --graph --stat -p --full-diff $pretty_format_medium"; compdef _git gh=git-log - -# Git and svn mix -alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' -compdef _git git-svn-dcommit-push=git - -# -# Will return the current branch name -# Usage example: git pull origin $(current_branch) -# -function current_branch() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo ${ref#refs/heads/} -} - -# these aliases take advantage of the previous function -alias ggpull='git pull origin $(current_branch)' -compdef _git ggpull=git -alias ggpush='git push origin $(current_branch)' -compdef _git ggpush=git -alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' -compdef _git ggpnp=git +source $ZSH/plugins/git/git-aliases.plugin.zsh +source $ZSH/plugins/git/git-prompt-old.plugin.zsh +source $ZSH/plugins/git/git-prompt.plugin.zsh diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index be4710cd2..bf0932768 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -109,7 +109,7 @@ update__GIT_PROMPT_INFO () r="$_Cr_$r$R" fi - local _prompt="$b$r$s$i$p" + local _prompt="$b$r$i$s$p" # add ( ) around _prompt: if [ "$f" = 'yes' ]; then _prompt="($_prompt)" From acc1023bfd633b7b85d7ff287bddecced9d309d0 Mon Sep 17 00:00:00 2001 From: Ashley Dev Date: Thu, 2 Jun 2011 14:09:05 -0700 Subject: [PATCH 23/29] fix up the git prompt when it's a fresh repo --- plugins/git/git-prompt.plugin.zsh | 8 +++----- themes/ashleydev.zsh-theme | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/plugins/git/git-prompt.plugin.zsh b/plugins/git/git-prompt.plugin.zsh index 5b575be6c..bafe903e0 100644 --- a/plugins/git/git-prompt.plugin.zsh +++ b/plugins/git/git-prompt.plugin.zsh @@ -148,9 +148,7 @@ # # local _prompt="$b$r$i$s$p" # # add ( ) around _prompt: -# if [ $f = 'yes' ]; then -# _prompt="($_prompt)" -# elif [ "$u" = "yes" ]; then +# if [ "$u" = "yes" ]; then # _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" # elif [ "$u" = "no" ]; then # _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" @@ -539,11 +537,11 @@ _git_prompt__dirty_state () if [[ "$line" = \?\?* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes' fi - if [[ "$line" = \ M* ]]; then + if [[ "$line" = ?M* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes' GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' fi - if [[ "$line" = \ D* ]]; then + if [[ "$line" = ?D* ]]; then GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='yes' GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes' fi diff --git a/themes/ashleydev.zsh-theme b/themes/ashleydev.zsh-theme index bf0932768..15961b9c6 100644 --- a/themes/ashleydev.zsh-theme +++ b/themes/ashleydev.zsh-theme @@ -111,9 +111,7 @@ update__GIT_PROMPT_INFO () local _prompt="$b$r$i$s$p" # add ( ) around _prompt: - if [ "$f" = 'yes' ]; then - _prompt="($_prompt)" - elif [ "$u" = "yes" ]; then + if [ "$u" = "yes" ]; then _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)" elif [ "$u" = "no" ]; then _prompt="$_Cu_clean_($_prompt$_Cu_clean_)" From 9b63a03bcfb7a6c34281d7d905575c5647e9c8d2 Mon Sep 17 00:00:00 2001 From: Matt Doran Date: Sat, 4 Jun 2011 00:32:05 +1000 Subject: [PATCH 24/29] Fix typos in the svn plugin that would cause calls to 'svn' when not in an svn working copy. --- plugins/svn/svn.plugin.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 45d461306..86050227d 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -13,7 +13,7 @@ function in_svn() { } function svn_get_repo_name { - if [ is_svn ]; then + if [ in_svn ]; then svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" @@ -21,13 +21,13 @@ function svn_get_repo_name { } function svn_get_rev_nr { - if [ is_svn ]; then + if [ in_svn ]; then svn info 2> /dev/null | sed -n s/Revision:\ //p fi } function svn_dirty_choose { - if [ is_svn ]; then + if [ in_svn ]; then s=$(svn status 2>/dev/null) if [ $s ]; then echo $1 @@ -39,4 +39,4 @@ function svn_dirty_choose { function svn_dirty { svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN -} \ No newline at end of file +} From 0c41b1cdc3ff7b00ffb2310b91becb91b31704f7 Mon Sep 17 00:00:00 2001 From: Andrew Hodges Date: Fri, 3 Jun 2011 14:05:25 -0400 Subject: [PATCH 25/29] Colorize Install & Upgrade Scripts Make tools/install.sh and tools/upgrade.sh pretty. --- tools/install.sh | 28 ++++++++++++++-------------- tools/upgrade.sh | 21 +++++++++++---------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index 8ed1403af..aedb706da 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,36 +1,36 @@ if [ -d ~/.oh-my-zsh ] then - echo "You already have Oh My Zsh installed. You'll need to remove ~/.oh-my-zsh if you want to install" + echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install" exit fi -echo "Cloning Oh My Zsh..." +echo "\033[0;34mCloning Oh My Zsh...\033[0m" /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh -echo "Looking for an existing zsh config..." +echo "\033[0;34mLooking for an existing zsh config...\033[0m" if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] then - echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh"; + echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m"; cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh; rm ~/.zshrc; fi -echo "Using the Oh My Zsh template file and adding it to ~/.zshrc" +echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc -echo "Copying your current PATH and adding it to the end of ~/.zshrc for you." +echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" echo "export PATH=$PATH" >> ~/.zshrc -echo "Time to change your default shell to zsh!" +echo "\033[0;34mTime to change your default shell to zsh!\033[0m" chsh -s `which zsh` -echo ' __ __ ' -echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' -echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' -echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' -echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' -echo ' /____/' +echo "\033[0;32m"' __ __ '"\033[0m" +echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" +echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" +echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" +echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" +echo "\033[0;32m"' /____/ '"\033[0m" -echo "\n\n ....is now installed." +echo "\n\n \033[0;32m....is now installed.\033[0m" /usr/bin/env zsh source ~/.zshrc diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 6bdd02e38..7e5cc7655 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -1,12 +1,13 @@ current_path=`pwd` -echo "Upgrading Oh My Zsh" +echo "\033[0;34mUpgrading Oh My Zsh\033[0m" ( cd $ZSH && git pull origin master ) -echo ' __ __ ' -echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' -echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' -echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' -echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' -echo ' /____/' -echo "Hooray! Oh My Zsh has been updated and/or is at the current version. \nAny new updates will be reflected when you start your next terminal session." -echo "To keep up on the latest, be sure to follow Oh My Zsh on twitter: http://twitter.com/ohmyzsh" -cd $current_path \ No newline at end of file +echo "\033[0;32m"' __ __ '"\033[0m" +echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m" +echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m" +echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m" +echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" +echo "\033[0;32m"' /____/ '"\033[0m" +echo "\033[0;34mHooray! Oh My Zsh has been updated and/or is at the current version.\033[0m" +echo "\033[0;34mAny new updates will be reflected when you start your next terminal session.\033[0m" +echo "\033[0;34mTo keep up on the latest, be sure to follow Oh My Zsh on twitter: \033[1mhttp://twitter.com/ohmyzsh\033[0m" +cd $current_path From 7c9474508cade14102a2fe1c63ad845fda521bec Mon Sep 17 00:00:00 2001 From: vguerci Date: Sat, 4 Jun 2011 11:02:25 +0200 Subject: [PATCH 26/29] [upgrade] before init (no reload needed unless oh-my-zsh.sh has been modified) --- oh-my-zsh.sh | 17 ++++++++--------- tools/upgrade.sh | 1 - 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index dbff1ced9..2157c38a0 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,3 +1,11 @@ +# Check for updates on initial load... +if [ "$DISABLE_AUTO_UPDATE" = "true" ] +then + return +else + /usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh +fi + # Initializes Oh My Zsh # add a function path @@ -28,7 +36,6 @@ done for config_file ($ZSH/custom/*.zsh) source $config_file # Load the theme -# Check for updates on initial load... if [ "$ZSH_THEME" = "random" ] then themes=($ZSH/themes/*zsh-theme) @@ -41,11 +48,3 @@ else source "$ZSH/themes/$ZSH_THEME.zsh-theme" fi - -# Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" = "true" ] -then - return -else - /usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh -fi diff --git a/tools/upgrade.sh b/tools/upgrade.sh index 7e5cc7655..e30488822 100644 --- a/tools/upgrade.sh +++ b/tools/upgrade.sh @@ -8,6 +8,5 @@ echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m" echo "\033[0;32m"' /____/ '"\033[0m" echo "\033[0;34mHooray! Oh My Zsh has been updated and/or is at the current version.\033[0m" -echo "\033[0;34mAny new updates will be reflected when you start your next terminal session.\033[0m" echo "\033[0;34mTo keep up on the latest, be sure to follow Oh My Zsh on twitter: \033[1mhttp://twitter.com/ohmyzsh\033[0m" cd $current_path From 9b4a89f327a045ed5e756ae4e75d1aac68803164 Mon Sep 17 00:00:00 2001 From: Michael Komitee Date: Sat, 4 Jun 2011 14:03:10 -0400 Subject: [PATCH 27/29] Fix bug from Pull request #395 #395 broke oh-my-zsh for users who disable check-for-updates --- oh-my-zsh.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 2157c38a0..d72d90cf9 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,8 +1,6 @@ # Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" = "true" ] +if [ "$DISABLE_AUTO_UPDATE" != "true" ] then - return -else /usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh fi From c23e02722e6d5be0dcea68d78c1197944d95f352 Mon Sep 17 00:00:00 2001 From: Locojay Date: Sun, 5 Jun 2011 20:38:21 -0400 Subject: [PATCH 28/29] ashlydev --- plugins/git/git-prompt-old.plugin.zsh | 36 +-------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/plugins/git/git-prompt-old.plugin.zsh b/plugins/git/git-prompt-old.plugin.zsh index 7be7d1c26..bb7f05381 100644 --- a/plugins/git/git-prompt-old.plugin.zsh +++ b/plugins/git/git-prompt-old.plugin.zsh @@ -46,14 +46,8 @@ function git_prompt_long_sha() { fi } -<<<<<<< HEAD -# Get the status of the working tree -git_prompt_status() { -<<<<<<< HEAD -======= # Gets the status of the working tree. function git_prompt_status() { ->>>>>>> ashleydev/master local indicators line untracked added modified renamed deleted while IFS=$'\n' read line; do if [[ "$line" =~ '^\?\? ' ]]; then @@ -82,33 +76,5 @@ function git_prompt_status() { fi done < <(git status --porcelain 2> /dev/null) echo $indicators -======= - INDEX=$(git status --porcelain 2> /dev/null) - STATUS="" - if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" - fi - if $(echo "$INDEX" | grep '^A ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS" - fi - if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" - fi - if $(echo "$INDEX" | grep '^R ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS" - fi - if $(echo "$INDEX" | grep '^D ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" - fi - if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then - STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" - fi - echo $STATUS ->>>>>>> robbyrussel/master } + From d2bf5b9226c7bc1f44fe7372dc1ca7889b95acf2 Mon Sep 17 00:00:00 2001 From: Locojay Date: Sun, 5 Jun 2011 20:41:46 -0400 Subject: [PATCH 29/29] merge --- oh-my-zsh.sh | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 887439a62..8c565b8f9 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -48,21 +48,3 @@ else source "$ZSH/themes/$ZSH_THEME.zsh-theme" fi -<<<<<<< HEAD -# Load all of your custom configurations from custom/ -for config_file ($ZSH/custom/*.zsh) source $config_file - -# Compile zcompdump, if modified, to increase startup speed. -if [ "$HOME/.zcompdump" -nt "$HOME/.zcompdump.zwc" -o ! -e "$HOME/.zcompdump.zwc" ]; then - zcompile "$HOME/.zcompdump" -fi - -# Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" = "true" ] -then - return -else - /usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh -fi -======= ->>>>>>> robbyrussel/master