This repository was archived by the owner on Apr 24, 2020. It is now read-only.
[Enhancement] Refactor command_execution_time segment#1215
Open
ChrisBaker97 wants to merge 4 commits intoPowerlevel9k:masterfrom
Open
[Enhancement] Refactor command_execution_time segment#1215ChrisBaker97 wants to merge 4 commits intoPowerlevel9k:masterfrom
ChrisBaker97 wants to merge 4 commits intoPowerlevel9k:masterfrom
Conversation
Signed-off-by: Chris Baker <ChrisBaker97@users.noreply.github.com>
Signed-off-by: Chris Baker <ChrisBaker97@users.noreply.github.com>
Signed-off-by: Chris Baker <ChrisBaker97@users.noreply.github.com>
romkatv
added a commit
to romkatv/powerlevel10k
that referenced
this pull request
Jun 20, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a back-port of #1214 on the
nextbranch.I wanted to add an "s" after the seconds display, in the case that the execution time was under a minute, to make it clearer what units were being displayed, when there were no colons.
In the process of investigating this modification, I noticed that the code for formatting either whole or partial seconds (depending on the POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION variable) seemed unnecessarily complex. By eliminating the pre-declaration of the number type and replacing it with a printf statement to format on the fly, I was able to squash a three-way if/elif/else control structure into a single line.
I also noticed that all this formatting was being done every time, regardless of whether the execution time actually exceeded the threshold, so I moved that logic to the front of the module, so that none of those computations happen if nothing will be displayed anyway.