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

add haskell_stack prompt segment (#535)

This commit is contained in:
romkatv 2020-02-29 12:10:58 +01:00
parent 1c5358e0d5
commit 18701f4e49
7 changed files with 121 additions and 1 deletions

View file

@ -281,6 +281,7 @@ enable as many segments as you like. It won't slow down your prompt or Zsh start
| `jenv` | java environment from [jenv](https://github.com/jenv/jenv) | | `jenv` | java environment from [jenv](https://github.com/jenv/jenv) |
| `plenv` | perl environment from [plenv](https://github.com/tokuhirom/plenv) | | `plenv` | perl environment from [plenv](https://github.com/tokuhirom/plenv) |
| `phpenv` | php environment from [phpenv](https://github.com/phpenv/phpenv) | | `phpenv` | php environment from [phpenv](https://github.com/phpenv/phpenv) |
| `haskell_stack` | haskell version from [stack](https://haskellstack.org/) |
| `node_version` | [node.js](https://nodejs.org/) version | | `node_version` | [node.js](https://nodejs.org/) version |
| `go_version` | [go](https://golang.org) version | | `go_version` | [go](https://golang.org) version |
| `rust_version` | [rustc](https://www.rust-lang.org) version | | `rust_version` | [rustc](https://www.rust-lang.org) version |

View file

@ -72,6 +72,7 @@
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) phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
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)
@ -1061,6 +1062,20 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172
# Hide haskell version if it doesn't come from one of these sources.
#
# shell: version is set by STACK_YAML
# local: version is set by stack.yaml up the directory tree
# global: version is set by the implicit global project (~/.stack/global-project/stack.yaml)
typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local)
# If set to false, hide haskell version if it's the same as in the implicit global project.
typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true
# Custom icon.
# typeset -g POWERLEVEL9K_HASKELL_STACK_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

@ -72,6 +72,7 @@
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) phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
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)
@ -1040,6 +1041,20 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=3
# Hide haskell version if it doesn't come from one of these sources.
#
# shell: version is set by STACK_YAML
# local: version is set by stack.yaml up the directory tree
# global: version is set by the implicit global project (~/.stack/global-project/stack.yaml)
typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local)
# If set to false, hide haskell version if it's the same as in the implicit global project.
typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true
# Custom icon.
# typeset -g POWERLEVEL9K_HASKELL_STACK_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

@ -72,6 +72,7 @@
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) phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
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)
@ -1040,6 +1041,20 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=172
# Hide haskell version if it doesn't come from one of these sources.
#
# shell: version is set by STACK_YAML
# local: version is set by stack.yaml up the directory tree
# global: version is set by the implicit global project (~/.stack/global-project/stack.yaml)
typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local)
# If set to false, hide haskell version if it's the same as in the implicit global project.
typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true
# Custom icon.
# typeset -g POWERLEVEL9K_HASKELL_STACK_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

@ -72,6 +72,7 @@
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) phpenv # php version from phpenv (https://github.com/phpenv/phpenv)
haskell_stack # haskell version from stack (https://haskellstack.org/)
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)
@ -1114,6 +1115,22 @@
# Custom icon. # Custom icon.
# typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐' # typeset -g POWERLEVEL9K_PHPENV_VISUAL_IDENTIFIER_EXPANSION='⭐'
##########[ haskell_stack: haskell version from stack (https://haskellstack.org/) ]###########
# Haskell color.
# typeset -g POWERLEVEL9K_HASKELL_STACK_FOREGROUND=0
# typeset -g POWERLEVEL9K_HASKELL_STACK_BACKGROUND=3
# Hide haskell version if it doesn't come from one of these sources.
#
# shell: version is set by STACK_YAML
# local: version is set by stack.yaml up the directory tree
# global: version is set by the implicit global project (~/.stack/global-project/stack.yaml)
typeset -g POWERLEVEL9K_HASKELL_STACK_SOURCES=(shell local)
# If set to false, hide haskell version if it's the same as in the implicit global project.
typeset -g POWERLEVEL9K_HASKELL_STACK_ALWAYS_SHOW=true
# Custom icon.
# typeset -g POWERLEVEL9K_HASKELL_STACK_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

@ -138,6 +138,7 @@ function _p9k_init_icons() {
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php' PHP_ICON 'php'
HASKELL_ICON 'hs'
) )
;; ;;
'awesome-fontconfig') 'awesome-fontconfig')
@ -261,6 +262,7 @@ function _p9k_init_icons() {
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php' PHP_ICON 'php'
HASKELL_ICON 'hs'
) )
;; ;;
'awesome-mapped-fontconfig') 'awesome-mapped-fontconfig')
@ -387,6 +389,7 @@ function _p9k_init_icons() {
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php' PHP_ICON 'php'
HASKELL_ICON 'hs'
) )
;; ;;
'nerdfont-complete'|'nerdfont-fontconfig') 'nerdfont-complete'|'nerdfont-fontconfig')
@ -511,6 +514,7 @@ function _p9k_init_icons() {
ELIXIR_ICON '\uE62D' #  ELIXIR_ICON '\uE62D' # 
POSTGRES_ICON '\uE76E' #  POSTGRES_ICON '\uE76E' # 
PHP_ICON '\uE608' #  PHP_ICON '\uE608' # 
HASKELL_ICON '\uE61F' # 
) )
;; ;;
ascii) ascii)
@ -632,6 +636,7 @@ function _p9k_init_icons() {
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php' PHP_ICON 'php'
HASKELL_ICON 'hs'
) )
;; ;;
*) *)
@ -755,6 +760,7 @@ function _p9k_init_icons() {
ELIXIR_ICON 'elixir' ELIXIR_ICON 'elixir'
POSTGRES_ICON 'postgres' POSTGRES_ICON 'postgres'
PHP_ICON 'php' PHP_ICON 'php'
HASKELL_ICON 'hs'
) )
;; ;;
esac esac

View file

@ -4968,6 +4968,55 @@ _p9k_prompt_asdf_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[asdf]:-${${+functions[asdf]}:#0}}' typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='${commands[asdf]:-${${+functions[asdf]}:#0}}'
} }
_p9k_haskell_stack_version() {
if ! _p9k_cache_stat_get $0 $1 ${STACK_ROOT:-~/.stack}/{pantry/pantry.sqlite3,stack.sqlite3}; then
local v
v="$(STACK_YAML=$1 stack \
--silent \
--no-install-ghc \
--skip-ghc-check \
--no-terminal \
--color=never \
--lock-file=read-only \
query compiler actual)" || v=
_p9k_cache_stat_set "$v"
fi
_p9k__ret=$_p9k__cache_val[1]
}
prompt_haskell_stack() {
if [[ -n $STACK_YAML ]]; then
(( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)shell]} )) || return
_p9k_haskell_stack_version $STACK_YAML
else
(( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)local|global]} )) || return
if _p9k_upglob stack.yaml; then
(( _POWERLEVEL9K_HASKELL_STACK_PROMPT_ALWAYS_SHOW )) || return
(( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)global]} )) || return
_p9k_haskell_stack_version ${STACK_ROOT:-~/.stack}/global-project/stack.yaml
else
local -i idx=$?
(( ${_POWERLEVEL9K_HASKELL_STACK_SOURCES[(I)local]} )) || return
_p9k_haskell_stack_version $_p9k__parent_dirs[idx]/stack.yaml
fi
fi
[[ -n $_p9k__ret ]] || return
local v=$_p9k__ret
if (( !_POWERLEVEL9K_HASKELL_STACK_PROMPT_ALWAYS_SHOW )); then
_p9k_haskell_stack_version ${STACK_ROOT:-~/.stack}/global-project/stack.yaml
[[ $v == $_p9k__ret ]] && return
fi
_p9k_prompt_segment "$0" "yellow" "$_p9k_color1" 'HASKELL_ICON' 0 '' "${v//\%/%%}"
}
_p9k_prompt_haskell_stack_init() {
typeset -g "_p9k__segment_cond_${_p9k__prompt_side}[_p9k__segment_index]"='$commands[stack]'
}
# Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with # Use two preexec hooks to survive https://github.com/MichaelAquilina/zsh-you-should-use with
# YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427. # YSU_HARDCORE=1. See https://github.com/romkatv/powerlevel10k/issues/427.
_p9k_preexec1() { _p9k_preexec1() {
@ -6609,6 +6658,8 @@ _p9k_init_params() {
_p9k_declare -b POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY 0 _p9k_declare -b POWERLEVEL9K_JAVA_VERSION_PROJECT_ONLY 0
_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_HASKELL_STACK_PROMPT_ALWAYS_SHOW 1
_p9k_declare -a POWERLEVEL9K_HASKELL_STACK_SOURCES -- shell local
_p9k_declare -b POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW 0 _p9k_declare -b POWERLEVEL9K_PHPENV_PROMPT_ALWAYS_SHOW 0
_p9k_declare -a POWERLEVEL9K_PHPENV_SOURCES -- shell local global _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
@ -7286,7 +7337,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=$'v64\1'${ZSH_VERSION}$'\1'${ZSH_PATCHLEVEL}$'\1' _p9k__param_pat=$'v65\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'