Skip to content
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
ChrisBaker97:master-refactor-command_execution_time
Open

[Enhancement] Refactor command_execution_time segment#1215
ChrisBaker97 wants to merge 4 commits intoPowerlevel9k:masterfrom
ChrisBaker97:master-refactor-command_execution_time

Conversation

@ChrisBaker97
Copy link
Contributor

This is a back-port of #1214 on the next branch.

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.

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

1 participant