diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2023-11-19 17:52:25 +0100 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2023-11-19 17:52:25 +0100 |
| commit | 1225086f3e1f520b5a35d2798ad29427cbee6e14 (patch) | |
| tree | 5790ff3867ab518ec2142de2684f699deab80310 | |
| parent | 3b0fcfa346f8114f9c82700cdac47d30d2964bc8 (diff) | |
bashrc: show run time of commands
| -rw-r--r-- | bashrc | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -47,6 +47,11 @@ case "$TERM" in ;; esac +before_command() { + command_timer=${command_timer:-$(date +%s)} +} +trap 'before_command' DEBUG + # prompt __prompt_command() { local exit_code=$? @@ -87,6 +92,13 @@ __prompt_command() { PS1+=" <$red_b$exit_code$reset>" fi + # runtime + local command_runtime=$(($(date +%s) - $command_timer)) + unset command_timer + if [ $command_runtime -gt 0 ]; then + PS1+=" (${command_runtime}s)" + fi + PS1+=" $red\$$reset > " } PROMPT_COMMAND=__prompt_command |
