From f8ae0494e82f75c5521f28cab2cb9607ff105535 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Thu, 31 Oct 2019 22:33:40 -0700 Subject: [PATCH] Adds dirstack segment to powerline themes --- .../powerline-multiline.theme.bash | 3 +++ themes/powerline-naked/powerline-naked.theme.bash | 3 +++ themes/powerline-plain/powerline-plain.theme.bash | 3 +++ themes/powerline/powerline.base.bash | 11 +++++++++++ themes/powerline/powerline.theme.bash | 3 +++ 5 files changed, 23 insertions(+) diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index a726c8df..d5915da6 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -69,6 +69,9 @@ 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:="§"} +DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}} +DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_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/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index bff10f57..b8a2ade6 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -63,6 +63,9 @@ 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:="§"} +DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}} +DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_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/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index a300cab9..9c207a60 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -60,6 +60,9 @@ 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:="§"} +DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}} +DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_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/powerline.base.bash b/themes/powerline/powerline.base.bash index 058569c2..d33b71c2 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -170,6 +170,17 @@ function __powerline_shlvl_prompt { fi } +function __powerline_dirstack_prompt { + if [[ "${#DIRSTACK[@]}" -gt 1 ]]; then + local depth=$(( ${#DIRSTACK[@]} - 1 )) + local prompt="${DIRSTACK_THEME_PROMPT_CHAR}" + if [[ "${depth}" -ge 2 ]]; then + prompt+="${depth}" + fi + echo "${prompt}|${DIRSTACK_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 38e1ef1b..310ffb55 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -64,6 +64,9 @@ 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:="§"} +DIRSTACK_THEME_PROMPT_COLOR=${POWERLINE_DIRSTACK_COLOR:=${CWD_THEME_PROMPT_COLOR}} +DIRSTACK_THEME_PROMPT_CHAR=${POWERLINE_DIRSTACK_CHAR:="←"} + POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"} safe_append_prompt_command __powerline_prompt_command