Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124

The timer_stop work also includes the task of converting the calculator to human readability, and that is probably more difficult than it should be. I’m not a designer, however, this is what Past Lee settled on after hours of researching samples.
That’s for bash when I ssh’d into my Linux cluster, but I run fish on MacOS. I have a different fish project to get the same results there, complete with hacks to turn the measurement into a human readable format. I made this code, and I am not guilty. Witness my StackOverflow-sourced kludge.
function fish_prompt --description 'Write out the prompt'
# Save the last status
set -l last_status $status
# Calculate the command duration if available
set -l cmd_duration ""
if set -q CMD_DURATION
# Convert milliseconds to microseconds for more precise comparison
set -l duration_us (math "$CMD_DURATION * 1000")
# Calculate different time units
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)")
# Format duration string
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
# Define unicode symbols for status
set -l checkmark "✓"
set -l cross "✗"
# Colors
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)
# First line
echo # New line
echo -n -s $dark_gray "("(date +%T)") $last_status " # Time in brackets and exit status
# Status indicator with exit status
if test $last_status -eq 0
echo -n -s $green $checkmark
else
echo -n -s $red $cross
end
# Actually echo the duration
echo -n -s $dark_gray " $cmd_duration"
# Do the rest of the prompt
echo
set -l host_color $purple
echo -n -s $host_color $USER "@" (prompt_hostname) $normal ":" $blue (prompt_pwd) $normal " \$ "
end
Spending my development years immersed in ANSI BBS graphics may have made me prefer beautiful text on my terminal to simple, button-pushing admin. Look, I know some people see the lightening of words and all kinds killing detection and promoting skimmingbut what can I say? I love them and I trust them. Maybe I play too much, but so be it. You can take my various weapons from my cold, dead hands.
To do this, I rely on a small program called GRC (for Generic Colorizer) to add lighting and colors to other devices. It is widely available and works without any additional features.
Nothing wrong with a little color!
Lee Hutchinson
There’s a bit of confusion (which I keep .bash_aliases as a good citizen) to produce beautiful output that does not change in some general rules:
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 also a big fan of making my numbers readable by people, and -h switch is therefore used liberally.
(Note that wrapping rules like ip in GRC they can sometimes do weird things if you’re doing other things. Be careful. Or don’t! It’s your computer, knock yourself out!)
Sharp-eyed readers will see from the screenshots that I’m using Terminal.app for MacOS for my final application, although there are better ways. I guess the excuse I have is that I’m comfortable with Terminal.app and nothing has taken me away. I have tested the suspects—Ghost, Lovestrong iTerm2 and its wonders tmux windows integrationas well as a new reinterpretation of what happens on a terminal like Warp.