diff --git a/README.md b/README.md index 1f6df86..6b5b790 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,7 @@ will create the symbolic link for each script in the \ directory. ## Development tools - [doctools2man](doctools2man) converts doctool to man pages. +- [how](how) shows dev cheat sheets using [cheat.sh](https://cheat.sh). - [robodoc2html](robodoc2html) converts a documentation in the robodoc format into html. - [utable](utable) shows a Unicode table. diff --git a/how b/how new file mode 100755 index 0000000..ab84d33 --- /dev/null +++ b/how @@ -0,0 +1,35 @@ +#!/bin/bash + +#Создан: вт 03 дек 2019 11:14:23 +#Изменён: вт 03 дек 2019 21:18:38 + +BINDIR=${SHELLRC}/bin/ + +SCRIPT=cheat.sh + +check_cheat() { + command -V "$SCRIPT" >/dev/null 2>&1 +} + +install_cheat() { + curl -sq https://cht.sh/:cht.sh > "${BINDIR}/${SCRIPT}" + + chmod +x "${BINDIR}/${SCRIPT}" + + echo "[INFO] cheat.sh has been installed to ${BINDIR}/${SCRIPT}." +} + +tip() { + if [[ $1 == @* ]]; then + CHTSH_QUERY_OPTIONS="style=borland" cheat.sh --shell "${1/@/}" + elif [[ $1 == %* ]]; then + echo stealth Q | CHTSH_QUERY_OPTIONS="style=borland" cheat.sh --shell "${1/\%/}" + else + CHTSH_QUERY_OPTIONS="style=borland" cheat.sh "$@" | less -R + fi +} + +check_cheat || install_cheat + +tip "$@" +