From f8ae0494e82f75c5521f28cab2cb9607ff105535 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Thu, 31 Oct 2019 22:33:40 -0700 Subject: [PATCH 1/2] 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 From e0c0a770d64eae605c4e0ac35e83b2601e38e378 Mon Sep 17 00:00:00 2001 From: David Farrell Date: Fri, 1 Nov 2019 22:32:25 -0700 Subject: [PATCH 2/2] Updates README files for dirstack segment --- themes/powerline-multiline/README.md | 2 ++ themes/powerline-naked/README.md | 2 ++ themes/powerline-plain/README.md | 2 ++ themes/powerline/README.md | 2 ++ 4 files changed, 8 insertions(+) diff --git a/themes/powerline-multiline/README.md b/themes/powerline-multiline/README.md index 604d66aa..856c2261 100644 --- a/themes/powerline-multiline/README.md +++ b/themes/powerline-multiline/README.md @@ -10,6 +10,7 @@ A colorful multiline theme, where the first line shows information about your sh * Current username and hostname * Current time * Current shell level +* Current dirstack level (`pushd` / `popd`) * 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 @@ -67,6 +68,7 @@ The contents of both prompt sides can be "reordered", all the "segments" (every * `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 +* `dirstack` - Show the current dirstack level (based on `DIRSTACK` environment variable), but only if the stack is not empty Two variables can be defined to set the order of the prompt segments: diff --git a/themes/powerline-naked/README.md b/themes/powerline-naked/README.md index 60bf722f..bc64ad66 100644 --- a/themes/powerline-naked/README.md +++ b/themes/powerline-naked/README.md @@ -10,6 +10,7 @@ A colorful theme, where shows a lot information about your shell session. * Current username and hostname * Current time * Current shell level +* Current dirstack level (`pushd` / `popd`) * 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 * `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 +* `dirstack` - Show the current dirstack level (based on `DIRSTACK` environment variable), but only if the stack is not empty A variable can be defined to set the order of the prompt segments: diff --git a/themes/powerline-plain/README.md b/themes/powerline-plain/README.md index 924eb2ac..71939323 100644 --- a/themes/powerline-plain/README.md +++ b/themes/powerline-plain/README.md @@ -8,6 +8,7 @@ A colorful theme, where shows a lot information about your shell session. * Current username and hostname * Current time * Current shell level +* Current dirstack level (`pushd` / `popd`) * 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 * `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 +* `dirstack` - Show the current dirstack level (based on `DIRSTACK` environment variable), but only if the stack is not empty A variable can be defined to set the order of the prompt segments: diff --git a/themes/powerline/README.md b/themes/powerline/README.md index 20d0bdd9..43447fe7 100644 --- a/themes/powerline/README.md +++ b/themes/powerline/README.md @@ -12,6 +12,7 @@ A colorful theme, where shows a lot information about your shell session. * Current username and hostname * Current time * Current shell level +* Current dirstack level (`pushd` / `popd`) * 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 @@ -67,6 +68,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * `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 +* `dirstack` - Show the current dirstack level (based on `DIRSTACK` environment variable), but only if the stack is not empty A variable can be defined to set the order of the prompt segments: