https://github.com/sombriks/mdexec
run bash scripts from markdown files
https://github.com/sombriks/mdexec
ava bash cli markdown
Last synced: 4 months ago
JSON representation
run bash scripts from markdown files
- Host: GitHub
- URL: https://github.com/sombriks/mdexec
- Owner: sombriks
- License: mit
- Created: 2025-05-05T18:53:04.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-12T13:37:20.000Z (about 1 year ago)
- Last Synced: 2025-10-01T21:55:34.261Z (9 months ago)
- Topics: ava, bash, cli, markdown
- Language: JavaScript
- Homepage:
- Size: 291 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# [mdexec][repo]
[][npm]
[][workflow]
[](LICENSE)
```bash
echo "Run bash scripts inside markdown files!"
```
## Installing
```bash
npm -g i mdexec
```
Run with `npx` if you prefer:
```bash
npx mdexec
```
## Usage
Run the first bash script contained in a `README.md` file in current directory:
```bash
mdexec 0
```
List all scripts from `README.md`:
```bash
mdexec
# or mdexec -l
```
Pass directory where to run and markdown file name, run the 4th script:
```bash
mdexec -f steps/intro.md -d ../example -s 3
```
Run `mdexec -h` for more details.
## Why
Sometimes documentation also offers a command to execute.
Would be nice exec such scripts from terminal.
Some IDE's already offers to execute scripts.
## How
Add some script blocks in your markdown document:
```bash
# Obi-Wan jumps
echo "Hello there!"
```
```bash
# Grievous salutes
echo "General Kenobi!"
```
```bash
for i in `ls`
do
echo $i
done
```
Then `mdexec` will present them:
## How
[0]:
# Obi-Wan jumps
echo "Hello there!"
[1]:
# Grievous salutes
echo "General Kenobi!"
[2]:
for i in `ls`
do
echo $i
done
### What about other shells
```bash
echo "for now,"
echo "only bash is supported"
```
## Further reading
- [Intellij plugin][intellij]
- (Abandoned) [VSCode plugin][vscode]
- [Jupyter notebooks][jupyter]
[repo]: https://github.com/sombriks/mdexec
[npm]: https://www.npmjs.com/package/mdexec
[workflow]: https://github.com/sombriks/mdexec/actions/workflows/node.js.yml
[intellij]: https://www.jetbrains.com/help/idea/markdown.html#run-commands
[vscode]: https://marketplace.visualstudio.com/items/?itemName=Sycl.markdown-command-runner
[jupyter]: https://jupyter.org