paxtonhare / demo-magic Goto Github PK
View Code? Open in Web Editor NEWA handy shell script that enables you to write repeatable demos in a bash environment.
License: MIT License
A handy shell script that enables you to write repeatable demos in a bash environment.
License: MIT License
Two questions:
Is there a way to keep my default prompt between each step?
I've tried the following in my script but it results in now prompt at all:
. ~/demo-magic.sh
DEMO_PROMPT="${PS1}"
pe "ls -l"
pe "echo 'Hello'"
I think it would be neat if cmd could simulate typing the beginning of the command.
For instance:
pe "htop"
# Copy-paste some pid
cmd "kill "
# wait for enter key like p, pe etc.
# simulates typing kill
# presenter pastes the pid and presses return to execute
Also, if you forgot you were on the cmd step, you don't accidentally end up executing an empty command while you were trying to trigger the next step. Instead you trigger something which has a visual feedback. I think this is better in terms of UX.
Using demo-magic on my machine (OSX with zsh
or bash
) won't respect NO_WAIT
, i.e. it will always directly run the commands without waiting for pressing return
.
I think the issue is here:
Line 99 in fc286d6
This does not test for a boolean true
or false
expression but whether the variable is set.
Explanation from here:
So, basically [ $foo ] will be true if $foo is non-empty. Not true or false, just non-empty. [ ! $foo ] is true if $foo is empty or undefined.
My workaround for now is unset NO_WAIT
which then works as expected with the current implementation.
First, this is really awesome.
One thing I'd like to be added. Often, a multi-line CLI shows better. Instead of one long line I prefer it like this:
sls stackstorm docker run \
--verbose \
--function InviteSlack \
--data
'{"body": {"first_name": "Donald", "email": "[email protected]"}}'
I put in a quick hack that works for my demo:
function pe() {
# print the command
p "$@"
# Clean from \n and \
c=${@//"\n"/}
c=${c//\\/}
# execute the command
eval "$c"
}
But it will eat \
symbols in some commands so not good enough for a PR.
So take this as an input.
Thanks again for an awesome tool!
Hi, how can I auto print this eval "$(curl -sL check.vapor.sh)"
and run upon enter?
I'm using zsh but i tried this and iTerm is printing the shell of vapor.sh it seems...
#!/usr/bin/env bash
########################
# include the magic
########################
. demo-magic.sh
########################
# Configure the options
########################
DEMO_PROMPT="${GREEN}โ ${CYAN}\W "
# hide the evidence
clear
# Put your stuff here
p "eval \"$(curl -sL check.vapor.sh)\""
Thanks for the cool script.
I wanted a few commands to execute directly. The suggested option in the Readme using wait
however causes the cursor on my shell to jump to the next line without prompt. This breaks the illusion of me typing. Also I didn't really like that I had to put a wait after each command when I wanted to opt in for NO_WAIT. Hence I defined a function:
# print and execute immediately
function pei {
NO_WAIT=true pe $1
}
# usage
pei "cd agilebank"
What do you think, could this be a nice addition? I'm happy to provide a pull request with updated docs.
How do you code control-c so the pe
interpreter will understand it?
Hi ๐
Thanks for this project! ๐ป
For my demo purposes I changed your script drastically to more "navigate" like (interactive) mode. You can see the script here: https://gist.github.com/bwplotka/c2021c9411ac10cc45ff24aa0e32837a
The goal for me was to be able to fast forward and fast backward any time during the demo. There are numerous cases like:
I am adding this issue to ask if you want to support such cases in your project? Would you like to add this script here? I could host it in my own github repo, but since the code and idea is inspired by your bash code, I am happy to contribute it here if you obviously want such contribution.
Note I am not bash master, it that does not allow flexible options and probably does not work across all, gazillion shell versions and distros etc etc (: So it would need some touches.
Cheers!
Hi, I would like to run a demo in a REPL, such as the interactive python shell. My issue is that pe
will wait for the end of the current command to go to the next, so just using pe for the REPL will not work. Is there any way to do that?
I want to use the same Oh-My-Zsh theme of the prompt in my terminal during the demo too. In particular, I'm using Agnoster theme, that use some nested functions for defining $PROMPT, so it seems it's not enough assigning the value of this variable to $DEMO_PROMPT. Someone can help me?
Hello, and thank you for demo-magic
. I've been using it to showcase demos of some APi interactions that I can script with curl
. Is there anyway you know of that I could employ to avoid displaying secrets like passwords or tokens?
As a limited example I'm doing things like this:
TOKEN="Bearer 908y712ugehjkljds"
comment "# Get the frobulator"
pe "curl --silent 'https://127.0.0.1:5000/frobulator' -H 'Authorization: $TOKEN' | jq"
... which results in a very long output as the command interpolates the full bearer token of 1500+ characters
Hi,
Thanks for this great tool. It helped me a lot to automate a live demo for a Webminar.
Would you add a paypal badge in the README
, so I can pay you a beer?
Today the buildpack programmatically recommends folks use the nginx-buildpack for customizing nginx.conf, however the documentation has not been updated to incorporate that yet: https://docs.cloudfoundry.org/buildpacks/staticfile/index.html
Is there a way to continue the demo on a newly created bash session? Something like:
pei "ssh 10.0.0.1"
# Subsequent commands run in the ssh session
pei "hostname"
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.