diff options
| -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 |
