GithubHelp home page GithubHelp logo

paxtonhare / demo-magic Goto Github PK

View Code? Open in Web Editor NEW
1.6K 33.0 212.0 193 KB

A handy shell script that enables you to write repeatable demos in a bash environment.

License: MIT License

Shell 100.00%
demo shell tool automated

demo-magic's Issues

Issue with wait not respected

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:

if [[ ! $NO_WAIT ]]; then

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.

Suggestion command for print+eval+nowait

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.

Support multi-line commands

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!

Use Oh-My-Zsh theme for the prompt during the demo

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?

How to execute eval?

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)\""

Keep default prompt

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'"

Hide secrets

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

Support passing command prefix to cmd

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.

Navigate mode.

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:

  • Commands needs to be retried suddenly
  • Someone from audience wants to reply some bit of demo
  • I want to show something in detail
    .. and probably more.

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!

Questions on use

Two questions:

  1. Is there an easy way to turn off the bolding of the executed command lines?
  2. Can I get demo-magic to pause at an empty prompt instead of the prompt not being printed until I leave pause mode?

Control-C

How do you code control-c so the pe interpreter will understand it?

REPL demo

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.