2021-10-18 01:19:51 +02:00
|
|
|
#!/usr/bin/env tuterm
|
|
|
|
|
|
|
|
depends unbuffer
|
|
|
|
if mode demo; then depends tmux; fi
|
|
|
|
|
|
|
|
configure() {
|
|
|
|
# Configure delays and colors (optional)
|
|
|
|
if mode demo; then
|
|
|
|
DELAY='0.08s'
|
|
|
|
DELAY_SEP='0.2s'
|
|
|
|
DELAY_PROMPT='1s'
|
|
|
|
TUTERM_NAME='cheat-demo'
|
|
|
|
else
|
|
|
|
TUTERM_NAME='cheat-tutorial'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# timeout a command but only in demo mode
|
|
|
|
demo_timeout() {
|
|
|
|
if mode demo; then
|
|
|
|
unbuffer timeout "$@"
|
|
|
|
else
|
|
|
|
"${@:2}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
demo_clear() {
|
|
|
|
if mode demo; then
|
|
|
|
clear
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_Message() {
|
|
|
|
Message "# $@"
|
|
|
|
}
|
|
|
|
alias M=_Message
|
|
|
|
|
2021-11-02 17:48:59 +01:00
|
|
|
generate_custom_vim_cheatsheet() {
|
2021-10-18 01:19:51 +02:00
|
|
|
echo "---"
|
2021-11-02 17:48:59 +01:00
|
|
|
echo "tags: [ custom, vim ]"
|
2021-10-18 01:19:51 +02:00
|
|
|
echo "---"
|
2021-11-02 17:48:59 +01:00
|
|
|
echo "# Open files in a horizontal split"
|
|
|
|
echo "vim -o file1 file2 ..."
|
|
|
|
echo "# Open files in a vertical split"
|
|
|
|
echo "vim -O file1 file2 ..."
|
|
|
|
echo "# Go to next buffer"
|
|
|
|
echo ":n"
|
|
|
|
echo "# Go to previous buffer"
|
|
|
|
echo -n ":N"
|
2021-10-18 01:19:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Print prompt but only in demo mode
|
|
|
|
demo_prompt() {
|
|
|
|
mode demo && prompt
|
|
|
|
}
|
|
|
|
|
|
|
|
run() {
|
|
|
|
# This is where the demo/tutorial happens # Command tracker
|
|
|
|
M "Read cheat sheets"
|
|
|
|
e cheat tar #
|
2021-11-02 17:55:07 +01:00
|
|
|
demo_timeout 2.5 cheat tar
|
2021-10-18 01:19:51 +02:00
|
|
|
|
|
|
|
demo_clear
|
|
|
|
M "Comes with many cheat sheets preinstalled"
|
|
|
|
e cheat -l #
|
|
|
|
demo_timeout 1.5 cheat -l
|
|
|
|
|
|
|
|
demo_clear
|
|
|
|
M "Search for a command"
|
|
|
|
e cheat -s git #
|
2021-11-02 17:55:07 +01:00
|
|
|
demo_timeout 2 cheat -s git
|
2021-10-18 01:19:51 +02:00
|
|
|
|
|
|
|
demo_clear
|
|
|
|
M "Organize cheat sheets by tag"
|
|
|
|
c cheat --tag vcs #
|
|
|
|
|
|
|
|
demo_prompt
|
2021-11-02 17:55:07 +01:00
|
|
|
mode demo && sleep 1.5
|
2021-10-18 01:19:51 +02:00
|
|
|
|
|
|
|
demo_clear
|
|
|
|
mkdir .cheat
|
2021-11-02 17:55:07 +01:00
|
|
|
generate_custom_vim_cheatsheet > .cheat/custom_vim
|
2021-10-18 01:19:51 +02:00
|
|
|
rm .lesshst
|
|
|
|
|
|
|
|
M "Local cheat sheets"
|
|
|
|
e tree -a #
|
|
|
|
tree -a --noreport
|
2021-11-02 17:55:07 +01:00
|
|
|
e cheat custom_vim #
|
|
|
|
cheat custom_vim
|
2021-10-18 01:19:51 +02:00
|
|
|
|
|
|
|
demo_prompt
|
|
|
|
if mode demo; then sleep 1.5; fi
|
|
|
|
|
|
|
|
demo_clear
|
|
|
|
M "Easily edit cheat sheets"
|
2021-11-02 17:55:07 +01:00
|
|
|
e cheat -e custom_vim #
|
2021-10-18 01:19:51 +02:00
|
|
|
if mode demo; then
|
|
|
|
# NOTE: A bit of a hack needed to display the editor
|
2021-11-02 18:25:30 +01:00
|
|
|
timeout 2 tmux new-session "tmux set status off; vim -R .cheat/custom_vim" >/dev/null
|
2021-10-18 01:19:51 +02:00
|
|
|
else
|
2021-11-02 17:55:07 +01:00
|
|
|
cheat -e custom_vim
|
2021-10-18 01:19:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
demo_clear
|
|
|
|
e cheat cheat #
|
|
|
|
demo_timeout 1 cheat cheat
|
|
|
|
|
|
|
|
# Demo ends here
|
|
|
|
if mode demo; then c exit; fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# vim: filetype=sh
|