import prompt improvements from Pure #6

Closed
paulirish opened this Issue Oct 15, 2012 · 2 comments

Projects

None yet

2 participants

@paulirish
Owner

https://gist.github.com/9e4f4673a3aa1610dc52

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'
}

also

i want to pull in his benchmarked fast git dirty check

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

@sindresorhus

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: https://gist.github.com/3898739
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...

@sindresorhus

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