1
0
Fork 0
mirror of https://github.com/romkatv/powerlevel10k.git synced 2024-11-21 20:00:07 +00:00

add phpenv prompt segment; see #499

This commit is contained in:
romkatv 2020-02-15 13:38:44 +01:00
parent e4e7ccec81
commit 245a420499
6 changed files with 116 additions and 1 deletions

View file

@ -66,6 +66,7 @@
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
jenv # java version from jenv (https://github.com/jenv/jenv) jenv # java version from jenv (https://github.com/jenv/jenv)
plenv # perl version from plenv (https://github.com/tokuhirom/plenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv)
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
kubecontext # current kubernetes context (https://kubernetes.io/) kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io) terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -260,7 +261,13 @@
.hg .hg
.node-version .node-version
.python-version .python-version
.go-version
.ruby-version .ruby-version
.lua-version
.java-version
.perl-version
.php-version
.tool-version
.shorten_folder_marker .shorten_folder_marker
.svn .svn
.terraform .terraform
@ -988,6 +995,17 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
###########[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############
# PHP color.
typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99
# Hide php version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global)
# If set to false, hide php version if it's the same as global:
# $(phpenv version-name) == $(phpenv global).
typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
################[ terraform: terraform workspace (https://www.terraform.io) ]################# ################[ terraform: terraform workspace (https://www.terraform.io) ]#################
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched. # in each pair defines a pattern against which the current terraform workspace gets matched.

View file

@ -66,6 +66,7 @@
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
jenv # java version from jenv (https://github.com/jenv/jenv) jenv # java version from jenv (https://github.com/jenv/jenv)
plenv # perl version from plenv (https://github.com/tokuhirom/plenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv)
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
kubecontext # current kubernetes context (https://kubernetes.io/) kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io) terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -261,6 +262,7 @@
.lua-version .lua-version
.java-version .java-version
.perl-version .perl-version
.php-version
.tool-version .tool-version
.shorten_folder_marker .shorten_folder_marker
.svn .svn
@ -972,6 +974,17 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
###########[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############
# PHP color.
typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=5
# Hide php version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global)
# If set to false, hide php version if it's the same as global:
# $(phpenv version-name) == $(phpenv global).
typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools. # Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext. # Tip: Remove the next line to always show kubecontext.

View file

@ -66,6 +66,7 @@
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
jenv # java version from jenv (https://github.com/jenv/jenv) jenv # java version from jenv (https://github.com/jenv/jenv)
plenv # perl version from plenv (https://github.com/tokuhirom/plenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv)
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
kubecontext # current kubernetes context (https://kubernetes.io/) kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io) terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -261,6 +262,7 @@
.lua-version .lua-version
.java-version .java-version
.perl-version .perl-version
.php-version
.tool-version .tool-version
.shorten_folder_marker .shorten_folder_marker
.svn .svn
@ -972,6 +974,17 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
###########[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############
# PHP color.
typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=99
# Hide php version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global)
# If set to false, hide php version if it's the same as global:
# $(phpenv version-name) == $(phpenv global).
typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]############# #############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools. # Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext. # Tip: Remove the next line to always show kubecontext.

View file

@ -66,6 +66,7 @@
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv) luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
jenv # java version from jenv (https://github.com/jenv/jenv) jenv # java version from jenv (https://github.com/jenv/jenv)
plenv # perl version from plenv (https://github.com/tokuhirom/plenv) plenv # perl version from plenv (https://github.com/tokuhirom/plenv)
phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
kubecontext # current kubernetes context (https://kubernetes.io/) kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io) terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html) aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -265,6 +266,7 @@
.lua-version .lua-version
.java-version .java-version
.perl-version .perl-version
.php-version
.tool-version .tool-version
.shorten_folder_marker .shorten_folder_marker
.svn .svn
@ -1040,6 +1042,18 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PLENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
###########[ phpenv: php version from phpenv (https://github.com/phpenv/phpenv) ]############
# PHP color.
# typeset -g POWERLEVEL9K_PHPENV_FOREGROUND=0
# typeset -g POWERLEVEL9K_PHPENV_BACKGROUND=5
# Hide php version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_PHPENV_SOURCES=(shell local global)
# If set to false, hide php version if it's the same as global:
# $(phpenv version-name) == $(phpenv global).
typeset -g POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
################[ terraform: terraform workspace (https://www.terraform.io) ]################# ################[ terraform: terraform workspace (https://www.terraform.io) ]#################
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element # POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched. # in each pair defines a pattern against which the current terraform workspace gets matched.

View file

@ -133,6 +133,7 @@ function _p9k_init_icons() {
ERLANG_ICON 'erl' ERLANG_ICON 'erl'
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php'
) )
;; ;;
'awesome-fontconfig') 'awesome-fontconfig')
@ -251,6 +252,7 @@ function _p9k_init_icons() {
ERLANG_ICON 'erl' ERLANG_ICON 'erl'
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php'
) )
;; ;;
'awesome-mapped-fontconfig') 'awesome-mapped-fontconfig')
@ -373,6 +375,7 @@ function _p9k_init_icons() {
ERLANG_ICON 'erl' ERLANG_ICON 'erl'
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php'
) )
;; ;;
'nerdfont-complete'|'nerdfont-fontconfig') 'nerdfont-complete'|'nerdfont-fontconfig')
@ -492,6 +495,7 @@ function _p9k_init_icons() {
ERLANG_ICON '\uE7B1 ' #  ERLANG_ICON '\uE7B1 ' # 
ELIXIR_ICON '\uE62D' #  ELIXIR_ICON '\uE62D' # 
POSTGRES_ICON '\uE76E' #  POSTGRES_ICON '\uE76E' # 
PHP_ICON '\uE608' # 
) )
;; ;;
*) *)
@ -610,6 +614,7 @@ function _p9k_init_icons() {
ERLANG_ICON 'erl' ERLANG_ICON 'erl'
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php'
) )
;; ;;
esac esac

View file

@ -2548,6 +2548,56 @@ _p9k_prompt_rbenv_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[rbenv]:-${${+functions[rbenv]}:#0}}' typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[rbenv]:-${${+functions[rbenv]}:#0}}'
} }
function _p9k_phpenv_global_version() {
_p9k_read_word ${PHPENV_ROOT:-$HOME/.phpenv}/version || _p9k__ret=system
}
prompt_phpenv() {
if [[ -n $PHPENV_VERSION ]]; then
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)shell]} )) || return
local v=$PHPENV_VERSION
else
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local|global]} )) || return
if [[ $PHPENV_DIR == (|.) ]]; then
_p9k_upglob .php-version
local -i idx=$?
if (( idx )) && _p9k_read_word $_p9k__parent_dirs[idx]/.php-version; then
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return
else
_p9k__ret=
fi
else
_p9k__ret=
[[ $PHPENV_DIR == /* ]] && local dir=$PHPENV_DIR || local dir="$_p9k__cwd_a/$PHPENV_DIR"
while true; do
if _p9k_read_word $dir/.php-version; then
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)local]} )) || return
break
fi
[[ $dir == / ]] && break
dir=${dir:h}
done
fi
if [[ -z $_p9k__ret ]]; then
(( _POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW )) || return
(( ${_POWERLEVEL9K_PHPENV_SOURCES[(I)global]} )) || return
_p9k_phpenv_global_version
fi
local v=$_p9k__ret
fi
if (( !_POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW )); then
_p9k_phpenv_global_version
[[ $v == $_p9k__ret ]] && return
fi
_p9k_prompt_segment "$0" "magenta" "$_p9k_color1" 'PHP_ICON' 0 '' "${v//\%/%%}"
}
_p9k_prompt_phpenv_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[phpenv]:-${${+functions[phpenv]}:#0}}'
}
function _p9k_luaenv_global_version() { function _p9k_luaenv_global_version() {
_p9k_read_word ${LUAENV_ROOT:-$HOME/.luaenv}/version || _p9k__ret=system _p9k_read_word ${LUAENV_ROOT:-$HOME/.luaenv}/version || _p9k__ret=system
} }
@ -6286,6 +6336,8 @@ _p9k_init_params() {
_p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1 _p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1
_p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global _p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_PHPENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_LUAENV_SOURCES -- shell local global _p9k_declare -a POWERLEVEL9K_LUAENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_JENV_PROMPT_ALWAYS_SHOW 0
@ -6957,7 +7009,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1 [[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit _p9k_deinit
fi fi
_p9k__param_pat=$'v46\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' _p9k__param_pat=$'v47\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1' _p9k__param_pat+=$'${#parameters[(I)POWERLEVEL9K_*]}\1${(%):-%n%#}\1$GITSTATUS_LOG_LEVEL\1'
_p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1' _p9k__param_pat+=$'$GITSTATUS_ENABLE_LOGGING\1$GITSTATUS_DAEMON\1$GITSTATUS_NUM_THREADS\1'
_p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays' _p9k__param_pat+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'