Merge pull request #1888 from clupasq/feature/powerline-command-duration

Add command duration to the powerline theme family
pull/1891/head
Noah Gorny 2021-06-10 16:04:28 +03:00 committed by GitHub
commit 9b62a5c4df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 0 deletions

View File

@ -70,6 +70,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o
* ``battery`` - Battery information (you'll need to enable the ``battery`` plugin)
* ``clock`` - Current time in ``HH:MM:SS`` format
* ``cwd`` - Current working directory including full folder hierarchy (c.f. ``wd``\ )
* ``duration`` - Duration of the last command. See :ref:`Command duration <command_duration>` for details.
* ``gcloud`` - Current gcloud active account
* ``hostname`` - Host name of machine
* ``in_toolbox`` - Show identifier if running inside a `toolbox <https://github.com/containers/toolbox>`_

View File

@ -94,6 +94,8 @@ COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="G "}
COMMAND_DURATION_PROMPT_COLOR=${POWERLINE_COMMAND_DURATION_COLOR:=129}
POWERLINE_LEFT_PROMPT=${POWERLINE_LEFT_PROMPT:="scm python_venv ruby node cwd"}
POWERLINE_RIGHT_PROMPT=${POWERLINE_RIGHT_PROMPT:="in_vim clock battery user_info"}

View File

@ -210,6 +210,11 @@ function __powerline_command_number_prompt() {
echo "${COMMAND_NUMBER_THEME_PROMPT_CHAR}\#|${COMMAND_NUMBER_THEME_PROMPT_COLOR}"
}
function __powerline_duration_prompt() {
local duration=$(_command_duration)
[[ -n "$duration" ]] && echo "${duration}|${COMMAND_DURATION_PROMPT_COLOR}"
}
function __powerline_left_segment() {
local params
IFS="|" read -ra params <<< "${1}"

View File

@ -91,6 +91,8 @@ COMMAND_NUMBER_THEME_PROMPT_CHAR=${POWERLINE_COMMAND_NUMBER_CHAR:="#"}
GCLOUD_THEME_PROMPT_COLOR=${POWERLINE_GCLOUD_COLOR:=161}
GCLOUD_CHAR=${POWERLINE_GCLOUD_CHAR:="G "}
COMMAND_DURATION_PROMPT_COLOR=${POWERLINE_COMMAND_DURATION_COLOR:=129}
POWERLINE_PROMPT=${POWERLINE_PROMPT:="user_info scm python_venv ruby node cwd"}
safe_append_prompt_command __powerline_prompt_command