diff --git a/README.md b/README.md index 57b4c17..4d1859a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,23 @@ cheat ===== + +
+ + + +
+ + This demo was created using + tuterm. + +

+ + Run tuterm doc/demo/cheat.tut in this repository for an interactive tutorial. + +
+
+ `cheat` allows you to create and view interactive cheatsheets on the command-line. It was designed to help remind \*nix system administrators of options for commands that they use frequently, but not frequently enough to diff --git a/doc/demo/README.md b/doc/demo/README.md new file mode 100644 index 0000000..0847214 --- /dev/null +++ b/doc/demo/README.md @@ -0,0 +1,13 @@ +# Automated demo/interactive tutorial + +[Tuterm](https://github.com/veracioux/tuterm) is used to create a fully automated real-time demonstration of the program. +The demonstration is generated from the script `cheat.tut`, and it can be +played in the terminal by running `tuterm -m demo cheat.tut`. + +To upload the demonstration, run `./asciinema_upload_and_create_svg.sh`. This +script will upload to asciinema and give you back the URL, and create the SVG +file `cheat_demo.svg`, both of which are meant to be included in the `README.md`. +The SVG file should be included in version control. If you open the script, you +will find some tweakable parameters. + +The `cheat.tut` can also serve as an interactive tutorial, if you run `tuterm cheat.tut`. diff --git a/doc/demo/asciinema_upload_and_create_svg.sh b/doc/demo/asciinema_upload_and_create_svg.sh new file mode 100644 index 0000000..e233328 --- /dev/null +++ b/doc/demo/asciinema_upload_and_create_svg.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env sh + +# NOTE: Change this to suit your needs + +TERM_WIDTH=80 +TERM_HEIGHT=18 +RECORDED_COMMAND="tuterm cheat.tut --mode demo" +alias copy='xsel -b' + +# Dependencies: +# - asciinema (https://github.com/asciinema/asciinema) +# - svg-term (https://github.com/marionebl/svg-term-cli) +# - xsel + +# Tuterm can be found here: +# https://github.com/veracioux/tuterm + +rm -f /tmp/cheat.cast + +stty cols "$TERM_WIDTH" rows "$TERM_HEIGHT" +# Record the command +asciinema rec -c "$RECORDED_COMMAND" /tmp/cheat.cast + +# Change terminal width and height +# NOTE: for some reason the yes command prints Broken pipe; this is a workaround +sed -e "1 s/\(\"width\": \)[0-9]\+/\1$TERM_WIDTH/" \ + -e "1 s/\(\"height\": \)[0-9]\+/\1$TERM_HEIGHT/" \ + -e '/Broken pipe/d' \ + -i /tmp/cheat.cast + +# Upload to asciinema.org +output="$(asciinema upload /tmp/cheat.cast)" +echo "$output" + +# Copy URL to clipboard +echo "$output" | grep 'https:' | sed 's/^\s*//' | copy + +# Create local SVG animation +cat /tmp/cheat.cast | svg-term --out cheat_demo.svg + +echo "SVG animation saved as 'cheat_demo.svg'" diff --git a/doc/demo/cheat_demo.svg b/doc/demo/cheat_demo.svg new file mode 100644 index 0000000..0d28a91 --- /dev/null +++ b/doc/demo/cheat_demo.svg @@ -0,0 +1 @@ +#Readcheatsheetscheat-demo~$cheat-demo~$ccheat-demo~$chcheat-demo~$checheat-demo~$cheacheat-demo~$cheatcheat-demo~$cheattar#Toextractanuncompressedarchive:tar-xvf/path/to/foo.tar#Tocreateanuncompressedarchive:tar-cvf/path/to/foo.tar/path/to/foo/#Toextracta.gzarchive:tar-xzvf/path/to/foo.tgz#Tocreatea.gzarchive:tar-czvf/path/to/foo.tgz/path/to/foo/#Tolistthecontentofan.gzarchive:tar-ztvf/path/to/foo.tgz#Toextracta.bz2archive:tar-xjvf/path/to/foo.tgz:#Comeswithmanycheatsheetspreinstalledcheat-demo~$cheat-cheat-demo~$cheat-ltitle:file:tags:7z/usr/share/cheat/cheatsheets/community/7zcommunity,compressionab/usr/share/cheat/cheatsheets/community/abcommunityacl/usr/share/cheat/cheatsheets/community/aclcommunityalias/usr/share/cheat/cheatsheets/community/aliascommunityansi/usr/share/cheat/cheatsheets/community/ansicommunityapk/usr/share/cheat/cheatsheets/community/apkcommunity,packagingapparmor/usr/share/cheat/cheatsheets/community/apparmorcommunityapt/usr/share/cheat/cheatsheets/community/aptcommunity,pacapt-cache/usr/share/cheat/cheatsheets/community/apt-cachecommunity,pacapt-get/usr/share/cheat/cheatsheets/community/apt-getcommunity,pacaptitude/usr/share/cheat/cheatsheets/community/aptitudecommunity,pac#Searchforacommandcheat-demo~$cheat-scheat-demo~$cheat-sgitbower(community)#Toinstallapackagefromgithub:bowerinstall<user>/<repo>find(community)#Tosearchallfileswhoarenotin.gitdirectory:find.!-iwholename'*.git*'-typefgit(community)#Tosetyouridentity:gitconfig--globaluser.name<name>gitconfig--globaluser.email<email>#Tosetyoureditor:gitconfig--globalcore.editor<editor>#Toenablecolor:#Organizecheatsheetsbytagcheat-demo~$cheat--tagcheat-demo~$cheat--tagvcstitle:file:tags:git/usr/share/cheat/cheatsheets/community/gitcommunity,vcshg/usr/share/cheat/cheatsheets/community/hgcommunity,vcssvn/usr/share/cheat/cheatsheets/community/svncommunity,vcs#Localcheatsheetscheat-demo~$treecheat-demo~$tree-a.└──.cheat└──custom_vimcheat-demo~$cheatccheat-demo~$cheatcustom_vim#Openfilesinahorizontalsplitvim-ofile1file2...#Openfilesinaverticalsplitvim-Ofile1file2...#Gotonextbuffer:n#Gotopreviousbuffer:N#Easilyeditcheatsheetscheat-demo~$cheat-echeat-demo~$cheat-ecustom_vim---tags:[custom,vim]#Openfilesinahorizontalsplit#Openfilesinaverticalsplit#Gotonextbuffer#Gotopreviousbuffer~".cheat/custom_vim"[readonly][noeol]11L,193B1,1Allcheat-demo~$cheatcheat#Toseeexampleusageofaprogram:cheat<command>#Toeditacheatsheetcheat-e<command>#Tolistavailablecheatsheetscheat-l#Tosearchavailablecheatsheetscheat-s<command>#Togetthecurrent`cheat'versioncheat-vcheat-demo~$exitcheat-demo~$cheattcheat-demo~$cheattaaptitude/usr/share/cheat/cheatsheetcheat-demo~$cheat-sgcheat-demo~$cheat-sgicheat-demo~$cheat--cheat-demo~$cheat--tcheat-demo~$cheat--tacheat-demo~$cheat--tagvcheat-demo~$cheat--tagvccheat-demo~$tcheat-demo~$trcheat-demo~$trecheat-demo~$tree-cheat-demo~$cheatcucheat-demo~$cheatcuscheat-demo~$cheatcustcheat-demo~$cheatcustocheat-demo~$cheatcustomcheat-demo~$cheatcustom_cheat-demo~$cheatcustom_vcheat-demo~$cheatcustom_vicheat-demo~$cheat-eccheat-demo~$cheat-ecucheat-demo~$cheat-ecuscheat-demo~$cheat-ecustcheat-demo~$cheat-ecustocheat-demo~$cheat-ecustomcheat-demo~$cheat-ecustom_cheat-demo~$cheat-ecustom_vcheat-demo~$cheat-ecustom_vi[23] 0:dash* "haris-gusic" 18:26 02-Nov-21".cheat/custom_vim"[readonly][noeol]11L,193Bcheat-demo~$cheatchcheat-demo~$cheatchecheat-demo~$cheatcheacheat-demo~$echeat-demo~$excheat-demo~$exi \ No newline at end of file