From bbbff94cca497103d0f9854f9d8a67b9049f59c9 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 31 Dec 2013 00:35:57 +0100 Subject: [PATCH 01/11] Fixes rvm_prompt_info() in lib/rvm.zsh --- lib/rvm.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rvm.zsh b/lib/rvm.zsh index e8744e61e..d14b45632 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -2,7 +2,7 @@ function rvm_prompt_info() { [ -f $HOME/.rvm/bin/rvm-prompt ] || return local rvm_prompt - rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) + rvm_prompt=$(eval "$HOME/.rvm/bin/rvm-prompt $ZSH_THEME_RVM_PROMPT_OPTIONS" 2>/dev/null) [[ "${rvm_prompt}x" == "x" ]] && return echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" } From 468b24a8d54f294ab9802cac3801ba580c5c4397 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 31 Dec 2013 01:06:14 +0100 Subject: [PATCH 02/11] Returns false when rvm is not found. --- lib/rvm.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rvm.zsh b/lib/rvm.zsh index d14b45632..04d116397 100644 --- a/lib/rvm.zsh +++ b/lib/rvm.zsh @@ -1,8 +1,8 @@ # get the name of the ruby version function rvm_prompt_info() { - [ -f $HOME/.rvm/bin/rvm-prompt ] || return + [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 local rvm_prompt rvm_prompt=$(eval "$HOME/.rvm/bin/rvm-prompt $ZSH_THEME_RVM_PROMPT_OPTIONS" 2>/dev/null) - [[ "${rvm_prompt}x" == "x" ]] && return + [[ "${rvm_prompt}x" == "x" ]] && return 1 echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" } From ae6ded5ad795a7f4174bc10a5a02e1c0502e1352 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 31 Dec 2013 01:15:35 +0100 Subject: [PATCH 03/11] Returns false when rbenv is not found. --- lib/rbenv.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/rbenv.zsh b/lib/rbenv.zsh index a8b6c323c..f58074b83 100644 --- a/lib/rbenv.zsh +++ b/lib/rbenv.zsh @@ -1,2 +1,4 @@ # using the rbenv plugin will override this with a real implementation -function rbenv_prompt_info() {} +function rbenv_prompt_info() { + return 1 +} From 7aa766168cead04f677b4828cc5c837f823f7cd7 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 31 Dec 2013 01:44:51 +0100 Subject: [PATCH 04/11] Adds chruby_prompt_info dummy function. --- lib/chruby.zsh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 lib/chruby.zsh diff --git a/lib/chruby.zsh b/lib/chruby.zsh new file mode 100644 index 000000000..b78d04f86 --- /dev/null +++ b/lib/chruby.zsh @@ -0,0 +1,4 @@ +# using the chruby plugin will override this with a real implementation +function chruby_prompt_info() { + return 1 +} From 8a887c505282b771193ac3ee6df05a1fa3f8426a Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 31 Dec 2013 02:11:02 +0100 Subject: [PATCH 05/11] Joins ruby prompt files and adds ruby_prompt_info. --- lib/chruby.zsh | 4 ---- lib/rbenv.zsh | 4 ---- lib/ruby_prompts.zsh | 22 ++++++++++++++++++++++ lib/rvm.zsh | 8 -------- 4 files changed, 22 insertions(+), 16 deletions(-) delete mode 100644 lib/chruby.zsh delete mode 100644 lib/rbenv.zsh create mode 100644 lib/ruby_prompts.zsh delete mode 100644 lib/rvm.zsh diff --git a/lib/chruby.zsh b/lib/chruby.zsh deleted file mode 100644 index b78d04f86..000000000 --- a/lib/chruby.zsh +++ /dev/null @@ -1,4 +0,0 @@ -# using the chruby plugin will override this with a real implementation -function chruby_prompt_info() { - return 1 -} diff --git a/lib/rbenv.zsh b/lib/rbenv.zsh deleted file mode 100644 index f58074b83..000000000 --- a/lib/rbenv.zsh +++ /dev/null @@ -1,4 +0,0 @@ -# using the rbenv plugin will override this with a real implementation -function rbenv_prompt_info() { - return 1 -} diff --git a/lib/ruby_prompts.zsh b/lib/ruby_prompts.zsh new file mode 100644 index 000000000..287b3ff0a --- /dev/null +++ b/lib/ruby_prompts.zsh @@ -0,0 +1,22 @@ +# get the name of the rvm ruby version +function rvm_prompt_info() { + [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 + local rvm_prompt + rvm_prompt=$(eval "$HOME/.rvm/bin/rvm-prompt $ZSH_THEME_RVM_PROMPT_OPTIONS" 2>/dev/null) + [[ "${rvm_prompt}x" == "x" ]] && return 1 + echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" +} + +# using the rbenv plugin will override this with a real implementation +function rbenv_prompt_info() { + return 1 +} + +# using the chruby plugin will override this with a real implementation +function chruby_prompt_info() { + return 1 +} + +function ruby_prompt_info() { + echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info) +} diff --git a/lib/rvm.zsh b/lib/rvm.zsh deleted file mode 100644 index 04d116397..000000000 --- a/lib/rvm.zsh +++ /dev/null @@ -1,8 +0,0 @@ -# get the name of the ruby version -function rvm_prompt_info() { - [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 - local rvm_prompt - rvm_prompt=$(eval "$HOME/.rvm/bin/rvm-prompt $ZSH_THEME_RVM_PROMPT_OPTIONS" 2>/dev/null) - [[ "${rvm_prompt}x" == "x" ]] && return 1 - echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" -} From c6aacf611d51f7c00d216f77c3b32174cc3bed9c Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 31 Dec 2013 02:45:09 +0100 Subject: [PATCH 06/11] Refactors ruby_prompts.zsh --- lib/ruby_prompts.zsh | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/ruby_prompts.zsh b/lib/ruby_prompts.zsh index 287b3ff0a..2ef334d5f 100644 --- a/lib/ruby_prompts.zsh +++ b/lib/ruby_prompts.zsh @@ -7,13 +7,9 @@ function rvm_prompt_info() { echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" } -# using the rbenv plugin will override this with a real implementation -function rbenv_prompt_info() { - return 1 -} - -# using the chruby plugin will override this with a real implementation -function chruby_prompt_info() { +# using the chruby and/or rbenv plugins will override +# these with real implementations +function chruby_prompt_info rbenv_prompt_info { return 1 } From 72392a2c27386706c78efe1ace9b84e602d9d1ff Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Mon, 6 Jan 2014 09:57:09 +0100 Subject: [PATCH 07/11] Adds all other dummy implementations. --- lib/ruby_prompts.zsh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/ruby_prompts.zsh b/lib/ruby_prompts.zsh index 2ef334d5f..9ca6e1fc7 100644 --- a/lib/ruby_prompts.zsh +++ b/lib/ruby_prompts.zsh @@ -1,3 +1,10 @@ +function chruby_prompt_info hg_prompt_info pyenv_prompt_info \ + rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \ + virtualenv_prompt_info { + return 1 +} + +# oh-my-zsh supports an rvm prompt by default # get the name of the rvm ruby version function rvm_prompt_info() { [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 @@ -7,12 +14,8 @@ function rvm_prompt_info() { echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" } -# using the chruby and/or rbenv plugins will override -# these with real implementations -function chruby_prompt_info rbenv_prompt_info { - return 1 -} - +# use this to enable users to see their ruby version, no matter which +# version management system they use function ruby_prompt_info() { echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info) } From 082607c165c6ae16b7b059e941c8bfa3eddabbb8 Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Mon, 6 Jan 2014 09:57:23 +0100 Subject: [PATCH 08/11] Adds documentation. --- lib/ruby_prompts.zsh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ruby_prompts.zsh b/lib/ruby_prompts.zsh index 9ca6e1fc7..1aaf9de17 100644 --- a/lib/ruby_prompts.zsh +++ b/lib/ruby_prompts.zsh @@ -1,3 +1,15 @@ +# *_prompt_info functions for usage in your prompt +# +# Plugin creators, please add your *_prompt_info function to the list +# of dummy implementations to help theme creators not receiving errors +# without the need of implementing conditional clauses. +# +# See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for +# git_prompt_info, bzr_prompt_info and nvm_prompt_info + +# Dummy implementations that return false to prevent command_not_found +# errors with themes, that implement these functions +# Real implementations will be used when the respective plugins are loaded function chruby_prompt_info hg_prompt_info pyenv_prompt_info \ rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \ virtualenv_prompt_info { From 85fde31991dc04f34450390e7d20992a7334c90a Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Mon, 6 Jan 2014 09:58:40 +0100 Subject: [PATCH 09/11] Renames the file to prompt_info_functions.zsh --- lib/{ruby_prompts.zsh => prompt_info_functions.zsh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lib/{ruby_prompts.zsh => prompt_info_functions.zsh} (100%) diff --git a/lib/ruby_prompts.zsh b/lib/prompt_info_functions.zsh similarity index 100% rename from lib/ruby_prompts.zsh rename to lib/prompt_info_functions.zsh From 2d6d9d525fbf791affef71e2d7fd0a0f2cd0c30c Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Mon, 6 Jan 2014 09:59:50 +0100 Subject: [PATCH 10/11] Fixes RPROMPT in af-magic.zsh-theme --- themes/af-magic.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme index 4cf282590..f241efb6a 100644 --- a/themes/af-magic.zsh-theme +++ b/themes/af-magic.zsh-theme @@ -27,7 +27,7 @@ eval my_gray='$FG[237]' eval my_orange='$FG[214]' # right prompt -PROMPT='$(virtualenv_prompt_info)$my_gray%n@%m%{$reset_color%}%' +RPROMPT='$(virtualenv_prompt_info)$my_gray%n@%m%{$reset_color%}%' # git settings ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075](branch:" From b0b79e0abae5f1d228e16c36174bad2bf7ba5fee Mon Sep 17 00:00:00 2001 From: LFDM <1986gh@gmail.com> Date: Tue, 7 Jan 2014 19:08:20 +0100 Subject: [PATCH 11/11] No need to eval in rvm_prompt_info! Just activate word-splitting. --- lib/prompt_info_functions.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh index 1aaf9de17..335c02a3d 100644 --- a/lib/prompt_info_functions.zsh +++ b/lib/prompt_info_functions.zsh @@ -21,7 +21,7 @@ function chruby_prompt_info hg_prompt_info pyenv_prompt_info \ function rvm_prompt_info() { [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 local rvm_prompt - rvm_prompt=$(eval "$HOME/.rvm/bin/rvm-prompt $ZSH_THEME_RVM_PROMPT_OPTIONS" 2>/dev/null) + rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) [[ "${rvm_prompt}x" == "x" ]] && return 1 echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" }