sys/user timeとか欲ければ time を使うのが良いですが、コマンドを実行した後で「あ、timeしておけばよかった!」ってことも多いわけですよ。後悔先にたたず。
そんなわけで、私のおすすめは、zsh で実行に6秒以上掛ったコマンドはすべからく時間を表示するようにしてます。これでビルドに一体どれくらい時間がかかったんだろう??って後で悩まなくてすみますヨ。
$ sleep 3
$ sleep 6
<Command took 0m 0s>
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
Initialized empty Git repository in /home/rook/OpenSource/linux-2.6/.git/
remote: Counting objects: 1457202, done.
remote: Compressing objects: 100% (234925/234925), done.
remote: Total 1457202 (delta 1211981), reused 1456232 (delta 1211241)
Receiving objects: 100% (1457202/1457202), 317.73 MiB | 903 KiB/s, done.
Resolving deltas: 100% (1211981/1211981), done.
Checking out files: 100% (31564/31564), done.
<Command took 19m 36s>
bashでもできるのかな?誰か教えて!
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 | |
} | |
それにしても GitHub 便利だな。
0 件のコメント:
コメントを投稿