aboutsummaryrefslogtreecommitdiff
path: root/config/zsh/plugins/timer.zsh
blob: 55056571263477b9495160408bbe715d66505bb2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
function preexec() {
  timer=$(($(date +%s%0N)/1000000))
  echo -n "\\x1b]133;A\\x1b\\" # OSC 133 for marking prompt
}

function precmd() {
  if [ $timer ]; then
    now=$(($(date +%s%0N)/1000000))
    elapsed=$(($now-$timer))

    export RPROMPT="%F{cyan}${elapsed}ms %{$reset_color%}"
    unset timer
  fi
}