now usable by all prompts

pull/1508/head
Ofir Shtrull 2020-02-27 20:53:35 +02:00
parent 78397ad598
commit 936a79f619
7 changed files with 28 additions and 7 deletions

View File

@ -155,6 +155,14 @@ function scm_prompt_info_common {
{ [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true { [[ ${SCM} == ${SCM_SVN} ]] && svn_prompt_info && return; } || true
} }
function terraform_workspace_prompt {
if _command_exists terraform ; then
if [ -d .terraform ]; then
echo -e "$(terraform workspace show 2>/dev/null)"
fi
fi
}
function git_prompt_minimal_info { function git_prompt_minimal_info {
SCM_STATE=${SCM_THEME_PROMPT_CLEAN} SCM_STATE=${SCM_THEME_PROMPT_CLEAN}

View File

@ -60,6 +60,7 @@ The contents of both prompt sides can be "reordered", all the "segments" (every
* `cwd` - Current working directory including full folder hierarchy (c.f. `wd`) * `cwd` - Current working directory including full folder hierarchy (c.f. `wd`)
* `hostname` - Host name of machine * `hostname` - Host name of machine
* `in_vim` - Show identifier if running in `:terminal` from vim * `in_vim` - Show identifier if running in `:terminal` from vim
* `k8s_context` - Show current kubernetes context
* `last_status` - Exit status of last run command * `last_status` - Exit status of last run command
* `python_venv` - Python virtual environment information (`virtualenv`, `venv` * `python_venv` - Python virtual environment information (`virtualenv`, `venv`
and `conda` supported) and `conda` supported)
@ -67,7 +68,6 @@ The contents of both prompt sides can be "reordered", all the "segments" (every
* `node` - Current node version (only `nvm` is supported) * `node` - Current node version (only `nvm` is supported)
* `scm` - Version control information, `git` * `scm` - Version control information, `git`
* `terraform` - Current terraform workspace * `terraform` - Current terraform workspace
* `k8s_context` - Show current kubernetes context
* `user_info` - Current user * `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder * `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in. hierarchy, only the directory you're currently in.

View File

@ -1,7 +1,8 @@
. "$BASH_IT/themes/powerline/powerline.base.bash" . "$BASH_IT/themes/powerline/powerline.base.bash"
function __powerline_left_segment { function __powerline_left_segment() {
local OLD_IFS="${IFS}"; IFS="|" local OLD_IFS="${IFS}"
IFS="|"
local params=( $1 ) local params=( $1 )
IFS="${OLD_IFS}" IFS="${OLD_IFS}"
local separator="" local separator=""
@ -28,6 +29,6 @@ function __powerline_left_segment {
((SEGMENTS_AT_LEFT += 1)) ((SEGMENTS_AT_LEFT += 1))
} }
function __powerline_left_last_segment_padding { function __powerline_left_last_segment_padding() {
LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}" LEFT_PROMPT+="$(set_color ${LAST_SEGMENT_COLOR} -) ${normal}"
} }

View File

@ -17,6 +17,9 @@ USER_INFO_SSH_CHAR=${POWERLINE_USER_INFO_SSH_CHAR:=" "}
USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=240} USER_INFO_THEME_PROMPT_COLOR=${POWERLINE_USER_INFO_COLOR:=240}
USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202} USER_INFO_THEME_PROMPT_COLOR_SUDO=${POWERLINE_USER_INFO_COLOR_SUDO:=202}
TERRAFORM_THEME_PROMPT_COLOR=${POWERLINE_TERRAFORM_COLOR:=161}
TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="t "}
PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "} PYTHON_VENV_CHAR=${POWERLINE_PYTHON_VENV_CHAR:="p "}
CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "} CONDA_PYTHON_VENV_CHAR=${POWERLINE_CONDA_PYTHON_VENV_CHAR:="c "}
PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35} PYTHON_VENV_THEME_PROMPT_COLOR=${POWERLINE_PYTHON_VENV_COLOR:=35}

View File

@ -52,13 +52,13 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* `hostname` - Host name of machine * `hostname` - Host name of machine
* `in_vim` - Show identifier if running in `:terminal` from vim * `in_vim` - Show identifier if running in `:terminal` from vim
* `k8s_context` - Show current kubernetes context * `k8s_context` - Show current kubernetes context
* `terraform` - Current terraform workspace
* `last_status` - Exit status of last run command * `last_status` - Exit status of last run command
* `python_venv` - Python virtual environment information (`virtualenv`, `venv` * `python_venv` - Python virtual environment information (`virtualenv`, `venv`
and `conda` supported) and `conda` supported)
* `ruby` - Current ruby version if using `rvm` * `ruby` - Current ruby version if using `rvm`
* `node` - Current node version (only `nvm` is supported) * `node` - Current node version (only `nvm` is supported)
* `scm` - Version control information, `git` * `scm` - Version control information, `git`
* `terraform` - Current terraform workspace
* `user_info` - Current user * `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder * `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in. hierarchy, only the directory you're currently in.

View File

@ -66,8 +66,8 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* `ruby` - Current ruby version if using `rvm` * `ruby` - Current ruby version if using `rvm`
* `node` - Current node version (only `nvm` is supported) * `node` - Current node version (only `nvm` is supported)
* `scm` - Version control information, `git` * `scm` - Version control information, `git`
* `user_info` - Current user
* `terraform` - Current terraform workspace * `terraform` - Current terraform workspace
* `user_info` - Current user
* `wd` - Working directory, like `cwd` but doesn't show the full folder * `wd` - Working directory, like `cwd` but doesn't show the full folder
hierarchy, only the directory you're currently in. hierarchy, only the directory you're currently in.
* `shlvl` - Show the current shell level (based on `SHLVL` environment variable), but only if you are not in root shell * `shlvl` - Show the current shell level (based on `SHLVL` environment variable), but only if you are not in root shell

View File

@ -50,6 +50,15 @@ function __powerline_terraform_prompt() {
fi fi
} }
function __powerline_terraform_prompt() {
local terraform_workspace=""
if [ -d .terraform ]; then
terraform_workspace="$(terraform_workspace_prompt)"
[[ -n "${terraform_workspace}" ]] && echo "${TERRAFORM_CHAR}${terraform_workspace}|${TERRAFORM_THEME_PROMPT_COLOR}"
fi
}
function __powerline_node_prompt { function __powerline_node_prompt {
local node_version="" local node_version=""