diff --git a/modules/openstack/functions/os-info b/modules/openstack/functions/os-info new file mode 100644 index 0000000..6803795 --- /dev/null +++ b/modules/openstack/functions/os-info @@ -0,0 +1,23 @@ +# +# Exposes information about the OpenStack environment via the $os_info associative +# array. +# + +# function os-info { + +local tenant +local tenant_format +local tenant_formatted + +unset os_info +typeset -gA os_info + +[[ -n "${OS_TENANT_NAME+1}" ]] && tenant="[${OS_TENANT_NAME}]" + +if [[ "$tenant" != (none|) ]]; then + zstyle -s ':prezto:module:openstack:info:tenant' format 'tenant_format' + zformat -f tenant_formatted "$tenant_format" "s:$tenant" + os_info[tenant]="$tenant_formatted" +fi + +# } diff --git a/modules/prompt/functions/prompt_damoekri_setup b/modules/prompt/functions/prompt_damoekri_setup index 4fe132d..d4b335c 100644 --- a/modules/prompt/functions/prompt_damoekri_setup +++ b/modules/prompt/functions/prompt_damoekri_setup @@ -27,6 +27,11 @@ prompt_damoekri_precmd() { if (( $+functions[ruby-info] )); then ruby-info fi + + # Get Openstack tenant information. + if (( $+functions[os-info] )); then + os-info + fi } function prompt_damoekri_setup { @@ -57,8 +62,11 @@ function prompt_damoekri_setup { # Set ruby-info parameters. zstyle ':prezto:module:ruby:info:version' format ' %F{yellow}%v%f' + # Set openstack tenant info + zstyle ':prezto:module:openstack:info:tenant' format '%s' + # Define prompts. - PROMPT='%F{cyan}${_prompt_damoekri_pwd}%f${editor_info[keymap]} ' + PROMPT='${os_info:+${os_info[tenant]} }%F{cyan}${_prompt_damoekri_pwd}%f${editor_info[keymap]} ' RPROMPT='${git_info:+${(e)git_info[rprompt]}}${ruby_info:+${ruby_info[version]}}' }