Skip to content
Bash extension for printing execution time for each command.
Branch: master
Clone or download
Latest commit 3f35429 Apr 24, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial functional commit. Jun 9, 2014
LICENSE Update Apr 24, 2017 - Added option to wrap to the next line if our output would overwrite May 23, 2016
bash_command_timer_screenshot.gif Add demo screenshot. Jun 9, 2014


Bash extension for printing timing information for each command line executed.


After the execution of each command line, the script prints out the total execution time (up to millisecond precision), followed by the current time. The execution time is formatted to be human readable; e.g., 2h 7m 42s301.


Demo Screen-cap


This script should run pretty much out of the box on modern Linux and Mac OS X systems. Please report any incompatibilities on on GitHub.

Note that this script will also conflict with any other script that uses the DEBUG trap and PROMPT_COMMAND.


To set up this extension, you can

  1. Download somewhere, and add the following to your ~/.bashrc (replace with actual path where you saved the script):

    source ~/
  2. Alternatively, you can simply copy and paste the contents of into your ~/.bashrc.

That's it :)


You can use the following options to tweak the behavior of the script. You can either make the changes in-place (at the top of the script) or put them after sourcing the script in your .bashrc. You can also modify them on-the-fly if you want the changes to only affect your current Bash session.

  • BCT_ENABLE=1: Setting this to 0 disables the printing of timings.
  • BCT_COLOR='34': The color of the output. This should be a color string usable in a VT100 escape sequence (see Wikipedia), without the escape sequence prefix and suffix. For example, bold red would be '1;31'.
  • BCT_TIME_FORMAT='%b %d %I:%M%p': The display format of the current time. This is a strftime format string (see If empty, the current time will not be printed.
  • BCT_MILLIS=1: Whether to print timings to millisecond precision. If set to zero, will print timings up to seconds.


For an explanation of how the script works, you're welcome to check out my blog post: DEBUG trap and PROMPT_COMMAND in Bash.

You can’t perform that action at this time.