Added runtime to zsh prompts
This commit is contained in:
parent
4570003c2b
commit
65c428525d
@ -352,7 +352,6 @@ version 3](LICENSE).
|
||||
* The analog clock requires a Unicode-aware terminal and at least a
|
||||
sufficiently complete font on your system. The [Symbola](http://users.teilar.gr/~g1951d/)
|
||||
font, designed by Georges Douros, is known to work well.
|
||||
* Displaying the runtime currently only works with Bash.
|
||||
|
||||
|
||||
## Authors
|
||||
|
44
liquidprompt
44
liquidprompt
@ -46,7 +46,7 @@
|
||||
# Rolf Morel <rolfmorel@gmail.com> # "Shorten path" refactoring and fixes
|
||||
# Thomas Debesse <thomas.debesse@gmail.com> # Fix columns use.
|
||||
# Yann 'Ze' Richard <ze@nbox.org> # Do not fail on missing commands.
|
||||
# Austen Adler <stonewareslord@gmail.com> # ZSH RPS1
|
||||
# Austen Adler <stonewareslord@gmail.com> # ZSH RPS1, ZSH runtime
|
||||
|
||||
# See the README.md file for a summary of features.
|
||||
|
||||
@ -297,11 +297,7 @@ _lp_source_config()
|
||||
LP_ENABLE_HG=${LP_ENABLE_HG:-1}
|
||||
LP_ENABLE_BZR=${LP_ENABLE_BZR:-1}
|
||||
LP_ENABLE_TIME=${LP_ENABLE_TIME:-0}
|
||||
if $_LP_SHELL_bash; then
|
||||
LP_ENABLE_RUNTIME=${LP_ENABLE_RUNTIME:-1}
|
||||
else
|
||||
LP_ENABLE_RUNTIME=${LP_ENABLE_RUNTIME:-0}
|
||||
fi
|
||||
LP_ENABLE_RUNTIME=${LP_ENABLE_RUNTIME:-1}
|
||||
LP_ENABLE_VIRTUALENV=${LP_ENABLE_VIRTUALENV:-1}
|
||||
LP_ENABLE_SCLS=${LP_ENABLE_SCLS:-1}
|
||||
LP_ENABLE_VCS_ROOT=${LP_ENABLE_VCS_ROOT:-0}
|
||||
@ -417,11 +413,6 @@ command -v screen >/dev/null ; _lp_bool _LP_ENABLE_SCREEN $?
|
||||
command -v tmux >/dev/null ; _lp_bool _LP_ENABLE_TMUX $?
|
||||
$_LP_ENABLE_SCREEN || $_LP_ENABLE_TMUX ; _lp_bool _LP_ENABLE_DETACHED_SESSIONS $?
|
||||
|
||||
if [[ "$LP_ENABLE_RUNTIME" == 1 ]] && ! $_LP_SHELL_bash; then
|
||||
echo Unfortunately, runtime printing for zsh is not yet supported. Turn LP_ENABLE_RUNTIME off in your config to hide this message.
|
||||
LP_ENABLE_RUNTIME=0
|
||||
fi
|
||||
|
||||
# If we are running in a terminal multiplexer, brackets are colored
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
LP_BRACKET_OPEN="${LP_COLOR_IN_MULTIPLEXER}${LP_MARK_BRACKET_OPEN}${NO_COL}"
|
||||
@ -1345,18 +1336,33 @@ _lp_runtime()
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$_LP_SHELL_zsh" ] ; then
|
||||
function precmd() {
|
||||
if [ $timer ]; then
|
||||
export _LP_RUNTIME_SECONDS=$(($SECONDS - $timer))
|
||||
unset timer
|
||||
fi
|
||||
}
|
||||
|
||||
function preexec() {
|
||||
export timer=${timer:-$SECONDS}
|
||||
}
|
||||
fi
|
||||
|
||||
_lp_reset_runtime()
|
||||
{
|
||||
# Compute number of seconds since program was started
|
||||
_LP_RUNTIME_SECONDS=$((SECONDS - _LP_RUNTIME_LAST_SECONDS))
|
||||
if $_LP_SHELL_bash; then
|
||||
# Compute number of seconds since program was started
|
||||
_LP_RUNTIME_SECONDS=$((SECONDS - _LP_RUNTIME_LAST_SECONDS))
|
||||
|
||||
# If no proper command was executed (i.e., someone pressed enter without entering a command),
|
||||
# reset the runtime counter
|
||||
[ "$_LP_RUNTIME_COMMAND_EXECUTED" != 1 ] && _LP_RUNTIME_LAST_SECONDS=$SECONDS && _LP_RUNTIME_SECONDS=0
|
||||
# If no proper command was executed (i.e., someone pressed enter without entering a command),
|
||||
# reset the runtime counter
|
||||
[ "$_LP_RUNTIME_COMMAND_EXECUTED" != 1 ] && _LP_RUNTIME_LAST_SECONDS=$SECONDS && _LP_RUNTIME_SECONDS=0
|
||||
|
||||
# A proper command has been executed if the last command was not related to Liquid Prompt
|
||||
[ "$BASH_COMMAND" = _lp_set_prompt ]
|
||||
_LP_RUNTIME_COMMAND_EXECUTED=$?
|
||||
# A proper command has been executed if the last command was not related to Liquid Prompt
|
||||
[ "$BASH_COMMAND" = _lp_set_prompt ]
|
||||
_LP_RUNTIME_COMMAND_EXECUTED=$?
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$LP_ENABLE_RUNTIME" = 1 ]
|
||||
|
Loading…
Reference in New Issue
Block a user