Created
January 31, 2010 15:02
-
-
Save ryo1kato/291104 to your computer and use it in GitHub Desktop.
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
# | |
# zsh script to show how long a command took to run | |
# put in your .zshrc | |
# | |
BG_BLUE='\e[0;44m' | |
OCOLOR='\e[0m' | |
BOLD='\e[1;39m' | |
prompt_command_start=0 | |
show_time_threash=5 | |
precmd() { | |
local prompt_command_duration=$((SECONDS - prompt_command_start)) | |
if [ $prompt_command_duration -gt $show_time_threash \ | |
-a $prompt_command_start -gt 0 ] | |
then | |
local min=$(( prompt_command_duration / 60 )) | |
local sec=$(( prompt_command_duration % 60 )) | |
echo -e "\e[0;44m\e[1;39m <Command took ${min}m ${sec}s> ${NOCOLOR}" | |
prompt_command_start=0 | |
fi | |
prompt_command_start=0 | |
} | |
preexec () { | |
prompt_command_start=$SECONDS | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment