Created
May 12, 2015 17:41
-
-
Save treyharris/c486c9f8776802e270b7 to your computer and use it in GitHub Desktop.
zsh library for demonstrating sequences of commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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