Powerlevel9k was a tool for building a beautiful and highly functional CLI, customized for you. P9k had a substantial impact on CLI UX, and its legacy is now continued by P10k.
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 P9K_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.
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
P9K_COMMAND_EXECUTION_TIME_PRECISION
variable) seemed unnecessarily complex. By eliminating the pre-declaration of the number type and replacing it with aprintf
statement to format on the fly, I was able to squash a three-wayif
/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.