diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index 965c593a..49ccb9f6 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -9,6 +9,7 @@ A colorful multiline theme, where the first line shows information about your sh * Current path * Current username and hostname * Current time +* Current shell level * An indicator when connected by SSH * An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor @@ -61,6 +62,7 @@ The contents of both prompt sides can be "reordered", all the "segments" (every * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder 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 Two variables can be defined to set the order of the prompt segments: diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index e90b494e..a70a2025 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -64,6 +64,9 @@ IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"} HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0} +SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}} +SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"} + POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby node cwd"} POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"} diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 1f16c296..60bf722f 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -9,6 +9,7 @@ A colorful theme, where shows a lot information about your shell session. * Current path * Current username and hostname * Current time +* Current shell level * An indicator when connected by SSH * An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor @@ -59,6 +60,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder 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 A variable can be defined to set the order of the prompt segments: diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 2a5b7b26..bff10f57 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -60,6 +60,9 @@ IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"} HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=254} +SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}} +SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index 6ea21a18..924eb2ac 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -7,6 +7,7 @@ A colorful theme, where shows a lot information about your shell session. * Current path * Current username and hostname * Current time +* Current shell level * An indicator when connected by SSH * An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor @@ -57,6 +58,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder 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 A variable can be defined to set the order of the prompt segments: diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 4d539470..a300cab9 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -57,6 +57,9 @@ IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"} HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0} +SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}} +SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command diff --git a/themes/powerline/README.md b/themes/powerline/README.md index acb51d9f..55efa655 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -11,6 +11,7 @@ A colorful theme, where shows a lot information about your shell session. * Current path * Current username and hostname * Current time +* Current shell level * An indicator when connected by SSH * An indicator when `sudo` has the credentials cached (see the `sudo` manpage for more info about this) * An indicator when the current shell is inside the Vim editor @@ -61,6 +62,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `user_info` - Current user * `wd` - Working directory, like `cwd` but doesn't show the full folder 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 A variable can be defined to set the order of the prompt segments: diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index a0f80552..f5cf4f3e 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -162,6 +162,14 @@ function __powerline_aws_profile_prompt { fi } +function __powerline_shlvl_prompt { + if [[ "${SHLVL}" -gt 1 ]]; then + local prompt="${SHLVL_THEME_PROMPT_CHAR}" + local level=$(( ${SHLVL} - 1)) + echo "${prompt}${level}|${SHLVL_THEME_PROMPT_COLOR}" + fi +} + function __powerline_left_segment { local OLD_IFS="${IFS}"; IFS="|" local params=( $1 ) diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 26182a82..d4bb387d 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -60,6 +60,9 @@ IN_VIM_THEME_PROMPT_TEXT=${POWERLINE_IN_VIM_TEXT:="vim"} HOST_THEME_PROMPT_COLOR=${POWERLINE_HOST_COLOR:=0} +SHLVL_THEME_PROMPT_COLOR=${POWERLINE_SHLVL_COLOR:=${HOST_THEME_PROMPT_COLOR}} +SHLVL_THEME_PROMPT_CHAR=${POWERLINE_SHLVL_CHAR:="§"} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command