diff options
| author | Peter Son Struschka <me@peter-struschka.com> | 2020-08-30 20:56:36 +0800 |
|---|---|---|
| committer | Peter Son Struschka <me@peter-struschka.com> | 2020-08-30 20:58:04 +0800 |
| commit | 37dd411698bd6eae8365260dde39b8ae9c7cbd36 (patch) | |
| tree | 978dd6ea3e72a86e4a3e0314b86d5137fc394785 /zsh/.local/bin | |
| parent | a1d6fc2f3e6ab041cc51cb085ac59a646a126d25 (diff) | |
| download | dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.gz dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.bz2 dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.lz dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.xz dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.tar.zst dotfiles-37dd411698bd6eae8365260dde39b8ae9c7cbd36.zip | |
all: overhaul, move dotfile specifics to .local/share/dotfiles and more
Diffstat (limited to 'zsh/.local/bin')
| -rwxr-xr-x | zsh/.local/bin/sort_timings.zsh | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/zsh/.local/bin/sort_timings.zsh b/zsh/.local/bin/sort_timings.zsh new file mode 100755 index 0000000..93b00e0 --- /dev/null +++ b/zsh/.local/bin/sort_timings.zsh @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +typeset -a lines +typeset -i prev_time=0 +typeset prev_command + +while read line; do + if [[ $line =~ '^.*\+([0-9]{10})\.([0-9]{6})[0-9]* (.+)' ]]; then + integer this_time=$match[1]$match[2] + + if [[ $prev_time -gt 0 ]]; then + time_difference=$(( $this_time - $prev_time )) + lines+="$time_difference $prev_command" + fi + + prev_time=$this_time + + local this_command=$match[3] + if [[ ${#this_command} -le 80 ]]; then + prev_command=$this_command + else + prev_command="${this_command:0:180}..." + fi + fi +done < ${1:-/dev/stdin} + +print -l ${(@On)lines} |
