From 37dd411698bd6eae8365260dde39b8ae9c7cbd36 Mon Sep 17 00:00:00 2001 From: Peter Son Struschka Date: Sun, 30 Aug 2020 20:56:36 +0800 Subject: all: overhaul, move dotfile specifics to .local/share/dotfiles and more --- zsh/.local/bin/sort_timings.zsh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 zsh/.local/bin/sort_timings.zsh (limited to 'zsh/.local/bin/sort_timings.zsh') 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} -- cgit v1.2.3