The `timer_stop` function simplifies the task of displaying timer results in a way that’s easy to read. After digging through various examples, I crafted a solution that works well for my needs, even if it’s a bit rough around the edges.
For my commands on MacOS, I use the fish shell instead of bash. I created a special fish function to get the same results, although it relies on some unconventional methods to format the timings. Here’s what I came up with—no apologies here! This is my very own creation from the depths of StackOverflow.
function fish_prompt --description 'Write out the prompt' set -l last_status $status set -l cmd_duration ""if set -q CMD_DURATION set -l duration_us (math "$CMD_DURATION * 1000") set -l us (math "$duration_us % 1000") set -l ms (math "floor($duration_us / 1000) % 1000") set -l s (math "floor($duration_us / 1000000) % 60") set -l m (math "floor($duration_us / 60000000) % 60") set -l h (math "floor($duration_us / 3600000000)") if test $h -gt 0 set cmd_duration (string join '' "(" $h "h" $m "m)") else if test $m -gt 0 set cmd_duration (string join '' "(" $m "m" $s "s)") else if test $s -ge 10 set -l fraction (math "floor($ms / 100)") set cmd_duration (string join '' "(" $s "." $fraction "s)") else if test $s -gt 0 set cmd_duration (string join '' "(" $s "." (printf "%03d" $ms) "s)") else if test $ms -ge 100 set cmd_duration (string join '' "(" $ms "ms)") else if test $ms -gt 0 set -l fraction (math "floor($us / 100)") set cmd_duration (string join '' "(" $ms "." $fraction "ms)") else set cmd_duration (string join '' "(" $us "us)") end end set -l checkmark "✓" set -l cross "✗" set -l normal (set_color normal) set -l dark_gray (set_color 555555) set -l blue (set_color -o blue) set -l red (set_color red) set -l green (set_color green) set -l purple (set_color -o purple) echo echo -n -s $dark_gray "["(date +%T)"] $last_status " if test $last_status -eq 0 echo -n -s $green $checkmark else echo -n -s $red $cross end echo -n -s $dark_gray " $cmd_duration" echo set -l host_color $purple echo -n -s $host_color $USER "@" (prompt_hostname) $normal ":" $blue (prompt_pwd) $normal " \$ "end
I’ve always had a soft spot for colorful terminals. Growing up with ANSI graphics, I find that a splash of color makes the shell experience more enjoyable. Sure, some argue that color can distract from comprehension, but I thrive on it. You can pry my vibrant shell tools from my hands when you pry my cold, dead fingers away!
To enhance my terminal’s color game, I use a handy tool called GRC (Generic Colorizer). It adds color to many command outputs without requiring complex setup. You can check it out on GitHub here.
I also set up some aliases in my `.bash_aliases` file to make colors the default for common commands. For example:
alias ls="ls --color=auto" alias ll="ls -AlFh --group-directories-first" alias df="grc df -h" alias du='grc du -h' alias free="grc free -h" alias ping='grc ping' alias traceroute="grc traceroute" alias ip='grc ip'I’m a firm believer in making numbers easy to read, so I often use the `-h` switch. But a word of caution: Using GRC might cause odd behavior if you’re piping output to other commands, so proceed with care—or don’t! It’s your computer.
As for my terminal choice, I stick with MacOS’s Terminal.app. I know there are flashier options out there, but I feel comfortable using it. I’ve tried several alternatives like iTerm2 and Alacritty, but I haven’t found one that beats my familiar Terminal.
Making commands colorful and prompts intuitive can improve your efficiency and experience in the terminal. While everyone has their preferences, don’t hesitate to explore different tools and tweaks. They might just make your coding life a little brighter!

