import prompt improvements from Pure #6

paulirish opened this Issue Oct 15, 2012 · 2 comments


None yet

2 participants


i had an idea to capture duration of longrunning tasks and automatically output their length if they surpass some threshold.

and then @sindresorhus wrote it!

preexec() {
    export PREEXEC_TIME=$(date +'%s')

precmd() {
    local stop=$(date +'%s')
    local start=${PREEXEC_TIME:-$stop}
    let elapsed=$stop-$start
    let max=5
    local cmd_time=`[ $elapsed -gt $max ] && echo ${elapsed}sec`
    print -P '\n $cmd_time'


i want to pull in his benchmarked fast git dirty check

@sindresorhus do you have a gist on all dirty checks and their speeds?


The above can be improved. Will implement it in Pure.

do you have a gist on all dirty checks and their speeds?

I've only done a quick stopwatch measurement with the WebKit git repo:
It's quite ironic that the native ZSH extension is the slowest...

Was planning to write a blog post about it, because so many gets that wrong, but u know, time hasn't been on my side lately...


Ok, I've improved the code and added it to my prompt. You can see a screenshot of it on the repo.

Since you're using Bash (com-on dude), you'll need a polyfill for the preexec method.

Also see my prompt for how to use that git dirty thing.

@paulirish paulirish closed this in 7e8e2ba Dec 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment