summaryrefslogtreecommitdiff
path: root/bashrc
diff options
context:
space:
mode:
Diffstat (limited to 'bashrc')
-rw-r--r--bashrc12
1 files changed, 12 insertions, 0 deletions
diff --git a/bashrc b/bashrc
index 5c58c9e..b587b0a 100644
--- a/bashrc
+++ b/bashrc
@@ -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