Skip to content

Instantly share code, notes, and snippets.

@treyharris
Created May 12, 2015 17:41
Show Gist options
  • Save treyharris/c486c9f8776802e270b7 to your computer and use it in GitHub Desktop.
Save treyharris/c486c9f8776802e270b7 to your computer and use it in GitHub Desktop.
zsh library for demonstrating sequences of commands
#!/bin/zsh
## Show shell commands in progress
## Usage:
## source $thisFile
##
# show "Explanation" "
# cmd 1
# cmd 2"
banner() {
# If COLUMNS is unset, we'll get 4 ='s ({1..-2})
local cols=$(($COLUMNS - 2))
printf "="%.0s {1..$cols}; print
echo "$@"
printf "="%.0s {1..$cols}; print
setopt xtrace
}
trace() {
PS4='> '
eval "setopt xtrace; $@"
}
show() {
banner "${argv[1]}"
trace "${argv[2,-1]}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment