Skip to content

Commit

Permalink
Merge pull request #12 from zakhenry/docs/asciinema
Browse files Browse the repository at this point in the history
docs(Readme): Add asciinema demo to readme
  • Loading branch information
zakhenry authored Jun 29, 2019
2 parents 3e3310f + 7504031 commit 30c34f0
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Simple utility to embed source files into markdown code blocks <sup>[why tho?](#
[![Build Status](https://travis-ci.org/zakhenry/embedme.svg?branch=master)](https://travis-ci.org/zakhenry/embedme)
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](https://commitizen.github.io/cz-cli/)

![Console Output](readme/screenshot.png 'Console Output')
![Demo](readme/asciinema/demo.svg)

## Usage

Expand All @@ -33,7 +33,7 @@ Et voilà! Your README.md file will be updated with the content of your source f
This is a *markdown* document with a code block:

```ts
// readme/example.ts
// example.ts

export function helloWorld(name: string): string {
return `Hello ${name}!, how are you today?`;
Expand Down Expand Up @@ -127,7 +127,7 @@ For example:

Will result in the following output

<!-- embedme readme/example.ts -->
<!-- embedme example.ts -->
This is a *markdown* document with a code block:

```ts
Expand Down
File renamed without changes.
60 changes: 60 additions & 0 deletions readme/asciinema/.bashrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
if [[ ! -z $ASCIINEMA_REC ]]; then

# profile built from ezprompt.net

function nonzero_return() {
RETVAL=$?
[ $RETVAL -ne 0 ] && echo "$RETVAL"
}

# get current branch in git repo
function parse_git_branch() {
BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
if [ ! "${BRANCH}" == "" ]
then
STAT=`parse_git_dirty`
echo "[${BRANCH}${STAT}]"
else
echo ""
fi
}

# get current status of git repo
function parse_git_dirty {
status=`git status 2>&1 | tee`
dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
bits=''
if [ "${renamed}" == "0" ]; then
bits=">${bits}"
fi
if [ "${ahead}" == "0" ]; then
bits="*${bits}"
fi
if [ "${newfile}" == "0" ]; then
bits="+${bits}"
fi
if [ "${untracked}" == "0" ]; then
bits="?${bits}"
fi
if [ "${deleted}" == "0" ]; then
bits="x${bits}"
fi
if [ "${dirty}" == "0" ]; then
bits="!${bits}"
fi
if [ ! "${bits}" == "" ]; then
echo " ${bits}"
else
echo ""
fi
}

export PS1="\[\e[34m\]\w\[\e[m\] \[\e[32m\]\`parse_git_branch\`\[\e[m\] \[\e[31m\]\`nonzero_return\`\[\e[m\] \[\e[37m\]\\$\[\e[m\] "

fi

15 changes: 15 additions & 0 deletions readme/asciinema/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Asciinema instructions

## setup

1. install https://asciinema.org/docs/installation
1. install https://github.com/marionebl/svg-term-cli
1. `cd readme/asciinema`
1. run `cat .bashrc >> ~/.bashrc` (if you haven't already) to set the prompt
1. create a new repo with a simple readme and example source code file

## record

1. run `ASCIINEMA_REC=1 asciinema rec demo.cast --command bash` and record the session
1. run `svg-term --in demo.cast --out demo.svg --window`
1. run `cp demo.* ../embedme/readme/asciinema`
43 changes: 43 additions & 0 deletions readme/asciinema/demo.cast
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{"version": 2, "width": 121, "height": 60, "timestamp": 1561842446, "env": {"SHELL": "/bin/zsh", "TERM": "xterm-256color"}}
[0.033895, "o", "\u001b[?1034h\u001b[34m~/repos/demo-project\u001b[m \u001b[32m\u001b[m \u001b[31m\u001b[m \u001b[37m$\u001b[m "]
[1.53075, "o", "c"]
[2.194579, "o", "a"]
[2.362113, "o", "t"]
[2.738741, "o", " "]
[3.230015, "o", "R"]
[3.402303, "o", "E"]
[3.62664, "o", "ADME.md "]
[4.161058, "o", "\r\n"]
[4.16378, "o", "# My Awesome Project\r\n\r\n```ts\r\n// example.ts\r\n```\r\n"]
[4.176117, "o", "\u001b[34m~/repos/demo-project\u001b[m \u001b[32m\u001b[m \u001b[31m\u001b[m \u001b[37m$\u001b[m "]
[5.894175, "o", "n"]
[6.076284, "o", "p"]
[6.208257, "o", "x"]
[6.384286, "o", " "]
[6.59626, "o", "e"]
[6.976219, "o", "m"]
[7.236352, "o", "b"]
[7.340119, "o", "e"]
[7.512215, "o", "d"]
[7.628282, "o", "m"]
[7.756312, "o", "e"]
[7.956989, "o", " "]
[8.197245, "o", "R"]
[8.588281, "o", "EADME.md "]
[9.628081, "o", "\r\n"]
[9.733475, "o", "\u001b[34mEmbedding...\u001b[39m\r\n"]
[9.735356, "o", "\u001b[35m Analysing \u001b[4mREADME.md\u001b[24m...\u001b[39m\r\n"]
[9.737251, "o", "\u001b[90m README.md#L3-L10\u001b[39m \u001b[32mEmbedded \u001b[92m4 lines\u001b[32m from file \u001b[4mexample.ts\u001b[24m\u001b[39m\r\n"]
[9.737489, "o", "\u001b[35m Writing \u001b[4mREADME.md\u001b[24m with embedded changes.\u001b[39m\r\n"]
[9.752726, "o", "\u001b[34m~/repos/demo-project\u001b[m \u001b[32m\u001b[m \u001b[31m\u001b[m \u001b[37m$\u001b[m "]
[11.84902, "o", "c"]
[12.012395, "o", "a"]
[12.180163, "o", "t"]
[12.326391, "o", " "]
[12.886483, "o", "R"]
[13.062608, "o", "E"]
[13.302162, "o", "ADME.md "]
[14.434319, "o", "\r\n"]
[14.436839, "o", "# My Awesome Project\r\n\r\n```ts\r\n// example.ts\r\n\r\nexport function helloWorld(name: string): string {\r\n return `Hello ${name}!, how are you today?`;\r\n}\r\n\r\n```\r\n"]
[14.451094, "o", "\u001b[34m~/repos/demo-project\u001b[m \u001b[32m\u001b[m \u001b[31m\u001b[m \u001b[37m$\u001b[m "]
[18.309716, "o", "exit\r\n"]
1 change: 1 addition & 0 deletions readme/asciinema/demo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed readme/screenshot.png
Binary file not shown.

0 comments on commit 30c34f0

Please sign in to comment.