Skip to content

Instantly share code, notes, and snippets.

@nriley
Created February 6, 2016 17:11
Show Gist options
  • Save nriley/34d92c9eb2eaf1073c04 to your computer and use it in GitHub Desktop.
Save nriley/34d92c9eb2eaf1073c04 to your computer and use it in GitHub Desktop.
Timestamp your command output with zsh
ts() {
local tspty=tspty.$(/usr/bin/uuidgen)
zmodload zsh/zpty
zpty $tspty $@
setopt localtraps
TRAPINT() { zpty -d $tspty }
while zpty -r $tspty line; do
print -Pn '%B%D{%m/%d %H:%M:%S}%b '
print -n -- $line
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment