From 782b5c4c57535bd16b551f7faa73924232e3678f Mon Sep 17 00:00:00 2001 From: Jus de Patate Date: Mon, 4 Feb 2019 11:50:43 +0100 Subject: [PATCH] Added basic teaching mode https://github.com/Bash-it/bash-it/issues/674 --- plugins/available/teachingmode.plugin.bash | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 plugins/available/teachingmode.plugin.bash diff --git a/plugins/available/teachingmode.plugin.bash b/plugins/available/teachingmode.plugin.bash new file mode 100644 index 00000000..e9702937 --- /dev/null +++ b/plugins/available/teachingmode.plugin.bash @@ -0,0 +1,34 @@ +# requested by greenrd on a issue https://github.com/Bash-it/bash-it/issues/674 + +function yes() { + if [ "$1" = "-ok" ]; then + shift + $(which yes) $* + else + echo "bash-it: this command will spam your terminal (use arg -ok to skip warning)" + exit 1 + fi +} +function ls() { + if [[ -f ${*: -1:1} ]]; then + echo "bash-it: ${*: -1:1} is a file not a folder" + exit 1 + else + $(which ls) $* + fi +} +function cat() { + if [[ -d ${*: -1:1} ]]; then + echo "bash-it: ${*: -1:1} is a folder not a file" + exit 1 + else + $(which cat) $* + fi +} +function rm() { + if [[ -d ${*: -1:1} ]]; then + $(which rm) -r $* + else + $(which rm) $* + fi +}