diff --git a/private_dot_config/zsh/dot_zshrc b/private_dot_config/zsh/dot_zshrc index 7d3bd97..53ad16d 100644 --- a/private_dot_config/zsh/dot_zshrc +++ b/private_dot_config/zsh/dot_zshrc @@ -113,8 +113,19 @@ POWERLINE_STOP="\ue0b4" PROMPT_ENTER="" #"\ueb70" precmd() { + local exec_ts=$(($(date +%s%N) - STARTCMD_TS)) + local seconds=$(echo "scale=9; $exec_ts / 1000000000" | bc) + local hours=$((seconds / 3600)) + local minutes=$(((seconds % 3600) / 60)) + seconds=$((seconds % 60)) + local exec_str=$(printf "%02d:%02d:%06.3f" hours minutes seconds) + print "" # empty line to increase readability - print -P "%F{${BG1}}${POWERLINE_START}%K{${BG1}}%F{${FG1}} %y on %M %K{${BG1}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}} %n %K{${BG2}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} %~ %K{${BG3}}%F{${FG4}}${POWERLINE_SEPARATOR}%k%F{${FG4}}${POWERLINE_STOP}" + print -P "%F{${BG1}}${POWERLINE_START}%K{${BG1}}%F{${FG1}} %y on %M %K{${BG1}}%F{${BG2}}${POWERLINE_SEPARATOR}%K{${BG2}}%F{${FG2}} %n %K{${BG2}}%F{${BG3}}${POWERLINE_SEPARATOR}%K{${BG3}}%F{${FG3}} %~ %K{${BG3}}%F{${FG4}}${POWERLINE_SEPARATOR}%k%F{${FG4}}${POWERLINE_STOP}%k%f...%K{${BG3}}%F{${FG3}} took ${exec_str} \uf252 %K{${BG2}}%F{${FG2}} at $(date +%H:%M:%S) \uf017" +} + +preexec() { + STARTCMD_TS=$(date +%s%N) } PROMPT="${PROMPT_ENTER} " # nord theme