-
Notifications
You must be signed in to change notification settings - Fork 944
Conversation
I was just looking into how to do this because I also think this is a great thing to have! Pulled the code and am testing. I couldn't find any icons that seemed terribly appropriate but for me the use case for this will be no icon and merged with the status segment. Could we make the "Dur" string a user setting? Something like POWERLEVEL9K_COMMAND_EXECUTION_TIME_STRING so it can be empty? One thing I did notice is that the segment position seems to affect the time. Here I have it on the left prompt and the right prompt and the right prompt segment execution seems to have a taken a little longer than the left prompt segment. In bullettrain they do the calculation in the precmd function which I assume gets around this. edit - it's the "2" joined to the status segment on the left prompt and the "3" on the very right of the right prompt. |
The hourglass-end seems awfully appropriate =] |
Thanks for the excellent feedback @rjorgenson And thanks @V1rgul for the icons. Btw. You use |
- Add a visual identifier - Fix a bug that the time was not reset - Make calculation independent of segment (thx @rjorgenson)
b757ef9
to
04e75a6
Compare
Thanks @V1rgul ! @rjorgenson I updated this PR according to your suggestions. "Dur" is now the visual identifier for the default icon set. For Btw. I skipped the tests, because we can't recreate interactive commands well enough in the tests. |
Been using this for the last day, and have noticed a lot of very very high second counts from things like ssh sessions and editing files etc. What do you think about something like this for a more readable output? Alternatively we could set a max threshold, but that information might be useful to people running hours long executions and having a readable output would be nice.
edit - forgot to account for sub 60 second times lol - fixed |
In 04e75a6#diff-ea5a405f0331722fc10a832209ffe20bR1185 I fixed a problem that the segment was not wiped, if you just press enter. That might be the problem in your case (or did you enter a command?).. |
No it wasn't a problem, I would just have a command executing for a significant period of time, in the case of SSH sessions, sometimes hours. This was giving me output in seconds that were almost meaningless to my maths challenged brain because it was more than a minute or two lol - The above would just output it in the form of MM:SS or HH:MM:SS if applicable. |
Ah. Now I see where you are getting at (sorry, too tired). Yes, great idea! 👍 |
Just noticed I left the 's' off the second output in my example above if you wanted to keep that. |
Thanks for the hint, but I'll leave it like this. If all outputs don't have units, then seconds should have none too. Btw. I noticed something strange, when I wrote tests for this: |
It actually returns 19:00:00 on my mac for some reason lol
I also get the exact same output on my Ubuntu test machine. It seems to be applying an offset to the hour for some reason rather than converting the epoch seconds to a time string. If I pass it 60 with the H:M:S date string it returns 17:01. It does appear to be calculating it correctly as 2 hours, but adding 17 hours to it somewhere, in your case it's probably just adding 1 hour. And for some reason on travis it's adding 0 hours. My TZ is GMT-7 so I don't think that's it, it is 17:XX PM right now where I am, so that may have something to do with it. I'll check it again at 18:XX PM and see if it changes. |
At 18:01 the strftime still returns the time plus 17 hours. Bizarre. |
Hmm, it does appear to be timezone related, if I run |
Yep. I am GMT+1. |
Anyway. Need to sleep now. Thanks for the help. Much appreciated! 👍 |
Awesome, looks like we can normalize TZ like so
And the tests pass as expected.
Enjoy your sleep! =] |
@rjorgenson @dritter - I'm testing this out, now, and for whatever reason the segment isn't rendering at all for me. I'm not really sure how to explain it, yet. Going to keep digging. |
@bhilburn by default if the command execution is less than 3 it will not display anything. Also for me it doesn't display anything if the execution time is less than 1 second even if threshold is set to 0. I've been testing by just opening up a file in vim for a number of seconds. |
@rjorgenson @dritter - Yeah, sorry, I should have been more specific. What I couldn't make it do was "always render". Like @rjorgenson said, setting the threshold to zero for some reason doesn't seem to work (neither do negative numbers). I think lots of people are going to be really excited by this segment, and want it to always be on. It would be great if there was a way to not only turn it perma-on, but display fractional seconds. Is there something similar to |
@bhilburn @dritter Hmmm, we could use I also had a thought on that and am not sure strftime is the best approach, since that's not actually what we want. I came up with this
This brings us back to specifying hours/minutes/seconds and away from a time string, which in hindsight -might- confuse someone who has the time segment enabled. Though the window for those two numbers being similar is slim. It is also does not yet account for OS specific date commands or gdate not being present on an OS X system. And given my admittedly limited understanding of what I wrote up there, it probably has a bug or two LOL - But it does work as I expect it to on my system. Probably worth pursuing if @bhilburn feels strongly about having this functionality in the theme. The segment is joined on the left to the return status, the first .021 was a clear command and not a new terminal, new terminal shows an empty value which is expected. P.S. - Sorry for the giant wall of text! |
I already found some bugs! lol I forgot to work in support for the threshold cutoff, that would need to be changed to |
- Change internal precision to nanoseconds - Let the user decide about desired precision - Add tests
@rjorgenson @bhilburn I reworked this segment. Now it uses nanoseconds internally (provided by Even setting If the command runs less than a minute, the microtime is printed as well. If you want, you could even control the precision by setting |
Well that's much slicker than what I came up with! Gonna pull this and give it a try tonight =] |
Tested out these changes and everything works great so far! |
@dritter @rjorgenson - Really great work, guys. When I'm not testing segments, my actual P9k config only used 6 segments. This just became the seventh segment in my permanent config |
This PR solves #330 . It is not complete by now, just wanted early feedback.
Still missing: