mirror of
https://github.com/Cornelicorn/bullet-train.zsh.git
synced 2025-12-06 20:00:38 +01:00
Add command execution time segment
This commit is contained in:
@@ -223,6 +223,13 @@ or don't want to see. All options must be overridden in your **.zshrc** file.
|
|||||||
|--------|-------|-------|
|
|--------|-------|-------|
|
||||||
|`BULLETTRAIN_HG_SHOW`|`true`|Show/hide that segment
|
|`BULLETTRAIN_HG_SHOW`|`true`|Show/hide that segment
|
||||||
|
|
||||||
|
### Command execution time
|
||||||
|
|
||||||
|
|Variable|Default|Meaning
|
||||||
|
|--------|-------|-------|
|
||||||
|
|`BULLETTRAIN_EXEC_TIME_SHOW`|`false`|Show/hide that segment
|
||||||
|
|`BULLETTRAIN_EXEC_TIME_ELAPSED`|5|Elapsed time of command execution
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
That project was originally a fork from
|
That project was originally a fork from
|
||||||
|
|||||||
@@ -244,6 +244,14 @@ else
|
|||||||
ZSH_THEME_GIT_PROMPT_DIVERGED=$BULLETTRAIN_GIT_PROMPT_DIVERGED
|
ZSH_THEME_GIT_PROMPT_DIVERGED=$BULLETTRAIN_GIT_PROMPT_DIVERGED
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# COMMAND EXECUTION TIME
|
||||||
|
if [ ! -n "${BULLETTRAIN_EXEC_TIME_SHOW+1}" ]; then
|
||||||
|
BULLETTRAIN_EXEC_TIME_SHOW=false
|
||||||
|
fi
|
||||||
|
if [ ! -n "${BULLETTRAIN_EXEC_TIME_ELAPSED+1}" ]; then
|
||||||
|
BULLETTRAIN_EXEC_TIME_ELAPSED=5
|
||||||
|
fi
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# SEGMENT DRAWING
|
# SEGMENT DRAWING
|
||||||
# A few functions to make it easy and re-usable to draw segmented prompts
|
# A few functions to make it easy and re-usable to draw segmented prompts
|
||||||
@@ -297,6 +305,22 @@ prompt_context() {
|
|||||||
[[ -n "$_context" ]] && prompt_segment $BULLETTRAIN_CONTEXT_BG $BULLETTRAIN_CONTEXT_FG "$_context"
|
[[ -n "$_context" ]] && prompt_segment $BULLETTRAIN_CONTEXT_BG $BULLETTRAIN_CONTEXT_FG "$_context"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Prompt previous command execution time
|
||||||
|
preexec() {
|
||||||
|
cmd_timestamp=`date +%s`
|
||||||
|
}
|
||||||
|
|
||||||
|
prompt_cmd_exec_time() {
|
||||||
|
if [[ $BULLETTRAIN_EXEC_TIME_SHOW == false ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local stop=`date +%s`
|
||||||
|
local start=${cmd_timestamp:-$stop}
|
||||||
|
let local elapsed=$stop-$start
|
||||||
|
[ $elapsed -gt $BULLETTRAIN_EXEC_TIME_ELAPSED ] && prompt_segment yellow white "${elapsed}s"
|
||||||
|
}
|
||||||
|
|
||||||
# Custom
|
# Custom
|
||||||
prompt_custom() {
|
prompt_custom() {
|
||||||
if [[ $BULLETTRAIN_CUSTOM_MSG == false ]]; then
|
if [[ $BULLETTRAIN_CUSTOM_MSG == false ]]; then
|
||||||
@@ -519,6 +543,7 @@ prompt_line_sep() {
|
|||||||
echo -e '\n%{\u200B%}'
|
echo -e '\n%{\u200B%}'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# MAIN
|
# MAIN
|
||||||
# Entry point
|
# Entry point
|
||||||
@@ -537,6 +562,7 @@ build_prompt() {
|
|||||||
prompt_go
|
prompt_go
|
||||||
prompt_git
|
prompt_git
|
||||||
prompt_hg
|
prompt_hg
|
||||||
|
prompt_cmd_exec_time
|
||||||
prompt_end
|
prompt_end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user