add luaenv prompt segment; see #342

pull/411/head
romkatv 5 years ago
parent e45af961da
commit 20a17daf15

@ -62,6 +62,7 @@
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io)
fvm # flutter version management (https://github.com/leoafarias/fvm)
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -720,6 +721,17 @@
# Custom icon.
# typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]###########
# Lua color.
typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32
# Hide lua version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global)
# If set to false, hide lua version if it's the same as global:
# $(luaenv version-name) == $(luaenv global).
typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
# Terraform color.
typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=38

@ -62,6 +62,7 @@
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io)
fvm # flutter version management (https://github.com/leoafarias/fvm)
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -696,6 +697,17 @@
# Custom icon.
# typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]###########
# Lua color.
typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=32
# Hide lua version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global)
# If set to false, hide lua version if it's the same as global:
# $(luaenv version-name) == $(luaenv global).
typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
# different contexts.

@ -62,6 +62,7 @@
rbenv # ruby version from rbenv (https://github.com/rbenv/rbenv)
rvm # ruby version from rvm (https://rvm.io)
fvm # flutter version management (https://github.com/leoafarias/fvm)
luaenv # lua version from luaenv (https://github.com/cehoffman/luaenv)
kubecontext # current kubernetes context (https://kubernetes.io/)
terraform # terraform workspace (https://www.terraform.io)
aws # aws profile (https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html)
@ -740,6 +741,18 @@
# Custom icon.
# typeset -g POWERLEVEL9K_FVM_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ luaenv: lua version from luaenv (https://github.com/cehoffman/luaenv) ]###########
# Lua color.
# typeset -g POWERLEVEL9K_LUAENV_FOREGROUND=0
# typeset -g POWERLEVEL9K_LUAENV_BACKGROUND=4
# Hide lua version if it doesn't come from one of these sources.
typeset -g POWERLEVEL9K_LUAENV_SOURCES=(shell local global)
# If set to false, hide lua version if it's the same as global:
# $(luaenv version-name) == $(luaenv global).
typeset -g POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW=false
# Custom icon.
# typeset -g POWERLEVEL9K_LUAENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
# Terraform color.
# typeset -g POWERLEVEL9K_TERRAFORM_FOREGROUND=4

@ -120,6 +120,7 @@ function _p9k_init_icons() {
DIRENV_ICON '\u25BC' # ▼
FLUTTER_ICON 'F'
GCLOUD_ICON 'G'
LUA_ICON 'lua'
)
;;
'awesome-fontconfig')
@ -227,6 +228,7 @@ function _p9k_init_icons() {
DIRENV_ICON '\u25BC' # ▼
FLUTTER_ICON 'F'
GCLOUD_ICON 'G'
LUA_ICON 'lua'
)
;;
'awesome-mapped-fontconfig')
@ -338,6 +340,7 @@ function _p9k_init_icons() {
DIRENV_ICON '\u25BC' # ▼
FLUTTER_ICON 'F'
GCLOUD_ICON 'G'
LUA_ICON 'lua'
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
@ -446,6 +449,7 @@ function _p9k_init_icons() {
DIRENV_ICON '\u25BC' # ▼
FLUTTER_ICON 'F'
GCLOUD_ICON '\uF7B7' # 
LUA_ICON '\uE620' # 
)
;;
*)
@ -553,6 +557,7 @@ function _p9k_init_icons() {
DIRENV_ICON '\u25BC' # ▼
FLUTTER_ICON 'F'
GCLOUD_ICON 'G'
LUA_ICON 'lua'
)
;;
esac

@ -2157,6 +2157,53 @@ prompt_rbenv() {
_p9k_prompt_segment "$0" "red" "$_p9k_color1" 'RUBY_ICON' 0 '' "${v//\%/%%}"
}
function _p9k_read_luaenv_version_file() {
[[ -r $1 ]] || return
local rest
read _p9k_ret rest <$1 2>/dev/null
[[ -n $_p9k_ret ]]
}
function _p9k_luaenv_global_version() {
_p9k_read_luaenv_version_file ${LUAENV_ROOT:-$HOME/.luaenv}/version || _p9k_ret=system
}
################################################################
# Segment to display luaenv information
# https://github.com/cehoffman/luaenv
prompt_luaenv() {
(( $+commands[luaenv] || $+functions[luaenv] )) || return
if [[ -n $LUAENV_VERSION ]]; then
(( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)shell]} )) || return
local v=$LUAENV_VERSION
else
(( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local|global]} )) || return
[[ $LUAENV_DIR == /* ]] && local dir=$LUAENV_DIR || local dir="$_p9k_pwd_a/$LUAENV_DIR"
while true; do
if _p9k_read_luaenv_version_file $dir/.lua-version; then
(( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)local]} )) || return
local v=$_p9k_ret
break
fi
if [[ $dir == / ]]; then
(( _POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW )) || return
(( ${_POWERLEVEL9K_LUAENV_SOURCES[(I)global]} )) || return
_p9k_luaenv_global_version
local v=$_p9k_ret
break
fi
dir=${dir:h}
done
fi
if (( !_POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW )); then
_p9k_luaenv_global_version
[[ $v == $_p9k_ret ]] && return
fi
_p9k_prompt_segment "$0" blue "$_p9k_color1" 'LUA_ICON' 0 '' "${v//\%/%%}"
}
################################################################
# Segment to display chruby information
# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH
@ -4934,6 +4981,8 @@ _p9k_init_params() {
_p9k_declare -b POWERLEVEL9K_RUST_VERSION_PROJECT_ONLY 1
_p9k_declare -b POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_RBENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_LUAENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_LUAENV_SOURCES -- shell local global
_p9k_declare -b POWERLEVEL9K_RVM_SHOW_GEMSET 0
_p9k_declare -b POWERLEVEL9K_RVM_SHOW_PREFIX 0
_p9k_declare -b POWERLEVEL9K_CHRUBY_SHOW_VERSION 1
@ -5520,7 +5569,7 @@ _p9k_must_init() {
[[ $sig == $_p9k__param_sig ]] && return 1
_p9k_deinit
fi
_p9k__param_pat=$'v18\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1'
_p9k__param_pat=$'v19\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\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+=$'$DEFAULT_USER\1${ZLE_RPROMPT_INDENT:-1}\1$P9K_SSH\1$__p9k_ksh_arrays'

Loading…
Cancel
Save