{"id":13505409,"url":"https://github.com/paxtonhare/demo-magic","last_synced_at":"2025-05-15T13:05:44.980Z","repository":{"id":45469058,"uuid":"43816458","full_name":"paxtonhare/demo-magic","owner":"paxtonhare","description":"A handy shell script that enables you to write repeatable demos in a bash environment.","archived":false,"fork":false,"pushed_at":"2025-04-29T20:32:16.000Z","size":194,"stargazers_count":1781,"open_issues_count":6,"forks_count":219,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-29T21:33:19.220Z","etag":null,"topics":["automated","demo","shell","tool"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/paxtonhare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-07T13:09:44.000Z","updated_at":"2025-04-29T21:03:42.000Z","dependencies_parsed_at":"2024-12-13T23:06:09.421Z","dependency_job_id":"04b034d4-bf30-437d-8298-4b33abc3de91","html_url":"https://github.com/paxtonhare/demo-magic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxtonhare%2Fdemo-magic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxtonhare%2Fdemo-magic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxtonhare%2Fdemo-magic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/paxtonhare%2Fdemo-magic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/paxtonhare","download_url":"https://codeload.github.com/paxtonhare/demo-magic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254346624,"owners_count":22055808,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automated","demo","shell","tool"],"created_at":"2024-08-01T00:01:05.833Z","updated_at":"2025-05-15T13:05:44.967Z","avatar_url":"https://github.com/paxtonhare.png","language":"Shell","funding_links":[],"categories":["shell","Shell","Languages and frameworks"],"sub_categories":["Shell"],"readme":"# Demo Magic\n\ndemo-magic.sh is a handy shell script that enables you to script repeatable demos in a bash environment so you don't have to type as you present. Rather than trying to type commands when presenting you simply script them and let demo-magic.sh run them for you.\n\n## Features\n- Simulates typing. It looks like you are actually typing out commands\n- Allows you to actually run commands or pretend to do so.\n- Can hide commands from presentation. Useful for behind the scenes stuff that doesn't need to be shown.\n\n## Functions\n\n### pe\nPrint and Execute.\n\n1. Waits for you to press \u003ckbd\u003eENTER\u003c/kbd\u003e (unless -n is passed).\n1. Then simulates typing the command you gave it.\n1. Then pauses until you press \u003ckbd\u003eENTER\u003c/kbd\u003e.\n1. Then runs the command.\n\n```bash\npe \"ls -l\"\n```\n\n### pei\nPrint and Execute immediately.\n\n1. Simulates typing the command you gave it.\n1. Then runs the command.\n\n```bash\npei \"ls -l\"\n```\n\n### p\nPrint only.\n\n1. Waits for you to press \u003ckbd\u003eENTER\u003c/kbd\u003e (unless -n is passed).\n1. Then simulates typing the command you gave it.\n1. Then pauses until you press \u003ckbd\u003eENTER\u003c/kbd\u003e.\n\n```bash\np \"ls -l\"\n```\n\n### wait\nWaits for the user to press \u003ckbd\u003eENTER\u003c/kbd\u003e.\n\nIf `PROMPT_TIMEOUT` is defined and \u003e 0 the demo will automatically proceed after the amount of seconds has passed.\n\n```bash\n# Will wait until user presses enter\nPROMPT_TIMEOUT=0\nwait\n\n# Will wait max 5 seconds until user presses\nPROMPT_TIMEOUT=5\nwait\n```\n\n### cmd\nEnters script into interactive mode and allows newly typed commands to be executed within the script\n```bash\ncmd\n```\n\n### repl\nEnters script into repl mode and allows newly typed commands to be executed within the script\nType: `exit` to leave repl mode\n```bash\nrepl\n```\n\n## Getting Started\nCreate a shell script and include demo-magic.sh\n\n```bash\n#!/bin/bash\n\n########################\n# include the magic\n########################\n. demo-magic.sh\n\n# hide the evidence\nclear\n\n# Put your stuff here\n```\n\nThen use the handy functions to run through your demo.\n\n## Handy Starting Points\nThere are a few samples in the `samples/` folder to show you how easy it is to get up and running.\n\nThe `demo-template.sh` is a bit of a showcase of some of the features.\n\nThe `remote-exec` folder is there to show you how to run demo-magic locally and on a remote server via ssh. This was created in response to [Issue #24](https://github.com/paxtonhare/demo-magic/issues/24)\n\nThe `self-setup` folder shows how you can setup an environment before starting your demo.\n\n## Command line usage\ndemo-magic.sh exposes some options to your script.\n- `-d` - disable simulated typing. Useful for debugging\n- `-h` - prints the usage text\n- `-n` - set no default waiting after `p` and `pe` functions\n- `-w` - set no wait timeout after `p` and `pe` functions\n\n```bash\n$ ./my-demo.sh -h\n\nUsage: ./my-demo.sh [options]\n\n  Where options is one or more of:\n  -h  Prints Help text\n  -d  Debug mode. Disables simulated typing\n  -n  No wait\n  -w  Waits max the given amount of seconds before proceeding with demo (e.g. `-w5`)\n```\n\n## Useful Tricks\n\n### Faking network connections\nNetwork connections during demos are often unreliable. Try and fake whatever commands would rely on a network connection. For example: Instead of trying to install node modules in a node.js application you can fake it. You can install the node_modules at home on your decent network. Then rename the directory and pretend to install it later by symlinking. If you want to be thorough you can capture the output of npm install into a log file then cat it out later to simulate the install.\n\n```bash\n#!/bin/bash\n\n########################\n# include the magic\n########################\n. demo-magic.sh\n\n# hide the evidence\nclear\n\n# this command is typed and executed\npe \"cd my-app\"\n\n# this command is merely typed. Not executed\np \"npm install\"\n\n# this command runs behind the scenes\nln -s cached_node_modules node_modules\n\n# cat out a log file that captures a previous successful node modules install\ncat node-modules-install.log\n\n# now type and run the command to start your app\npe \"node index.js\"\n```\n\n### No waiting\nThe -n _no wait_ option can be useful if you want to print and execute multiple commands.\n\n```bash\n# include demo-magic\n. demo-magic.sh -n\n\n# add multiple commands\npe 'git status'\npe 'git log --oneline --decorate -n 20'\n```\n\nHowever this will oblige you to define your waiting points manually e.g.\n```bash\n...\n# define waiting points\npe 'git status'\npe 'git log --oneline --decorate -n 20'\nwait\npe 'git pull'\npe 'git log --oneline --decorate -n 20'\nwait\n```\n\n### Pesky key cursor\n\nSome terminals (Mac terminal, [iterm2](https://iterm2.com/)) display a key cursor when input is masked.\n\n![Pesky Key Icon](_images/pesky-key-icon.png)\n\nYou can turn this off in [iterm2](https://iterm2.com/) like so:\n\n![Disable icon in iterm2](_images/iterm-disable-key.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxtonhare%2Fdemo-magic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpaxtonhare%2Fdemo-magic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpaxtonhare%2Fdemo-magic/lists"}