Last active
March 17, 2016 11:07
-
-
Save amitu/ae169bc7f2f4456358c7 to your computer and use it in GitHub Desktop.
ZSH: Print time to execute each command as it is executed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preexec () { | |
START="$(python -c 'import time; print time.time()')" | |
LAST_CMD=$1 | |
} | |
precmd () { | |
LAST=$? | |
if [ -z ${START} ]; | |
then | |
else | |
echo -n "Executed [$LAST_CMD: $LAST] in " | |
python -c "import time; print '%0.3fs.' % (time.time() - $START)" | |
fi | |
unset LAST | |
unset LAST_CMD | |
unset START | |
} |
True. But as long as you are exec
ing any external command, its all the same. Would be interesting if it can be done using only shell builtins tho.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't need python for this..