Last active
December 23, 2015 18:19
-
-
Save lauriro/6675170 to your computer and use it in GitHub Desktop.
Revisions
-
lauriro revised this gist
Sep 24, 2013 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Add to .bashrc or .zshrc and try it out # $ sleep 5 # -- Runs 5 seconds time_to_words() { local mod num="$1" out="" @@ -15,14 +15,14 @@ time_to_words() { echo $out } precmd() { CUR=`date +%s` RUN=`expr $CUR - ${PS_TIME-$CUR}` test $RUN -gt 4 && echo "-- Runs `time_to_words $RUN`" >&2 # Capture time trap 'PS_TIME=`date +%s`; trap DEBUG' DEBUG } PROMPT_COMMAND=precmd # for bash, zsh uses precmd directly -
lauriro created this gist
Sep 23, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # Add to .bashrc and try it out # $ sleep 5 # -- Runs: 5 seconds time_to_words() { local mod num="$1" out="" set -- 60 second 60 minute 24 hour 7 day 4 week 12 month while test $num -gt 0; do mod=`expr $num % $1` num=`expr $num / $1` test $mod -gt 0 && out="$mod $2`test $mod -gt 1 && echo s` $out" shift 2 done echo $out } prompt_command() { CUR=`date +%s` RUN=`expr $CUR - ${PS_TIME-$CUR}` test $RUN -gt 4 && echo "-- Runs: `time_to_words $RUN`" >&2 # Capture time trap 'PS_TIME=`date +%s`; trap DEBUG' DEBUG } PROMPT_COMMAND=prompt_command