aboutsummaryrefslogtreecommitdiffstats
path: root/help
diff options
context:
space:
mode:
authordanix <danix@danix.xyz>2018-12-18 15:12:50 +0100
committerdanix <danix@danix.xyz>2018-12-18 15:12:50 +0100
commit81873de46fa20d0d13ee44659850c07c2b247816 (patch)
tree8b81d4dd734ff90b8236564dcd8a9aaa673be3e9 /help
downloadgit_shell-81873de46fa20d0d13ee44659850c07c2b247816.tar.gz
git_shell-81873de46fa20d0d13ee44659850c07c2b247816.zip
initial commit
Diffstat (limited to 'help')
-rwxr-xr-xhelp32
1 files changed, 32 insertions, 0 deletions
diff --git a/help b/help
new file mode 100755
index 0000000..19d26ec
--- /dev/null
+++ b/help
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# usage: help - Lists all the available commands
+# help <command> - Detailled explanation of how "command" works
+
+if tty -s
+then
+ HELPTEXT="Hi $USER, Run 'help' for help, 'help <command>' for specific help on a command, run 'exit' to exit. Available commands:"
+else
+ HELPTEXT="Hi $USER, Run 'help' for help, 'help <command>' for specific help on a command. Available commands:"
+fi
+
+cd "$(dirname "$0")"
+
+if [[ ! -z $1 ]]; then
+ cmd=$1
+ if [[ -f $cmd && -x $cmd ]]; then
+ awk 'NR>=3&&NR<=4' $cmd | cut -c 3-
+ else
+ echo "command \"$cmd\" doesn't exists"
+ fi
+else
+ echo $HELPTEXT
+ for cmd in *
+ do
+ case "$cmd" in
+ help) ;;
+ *) [ -f "$cmd" ] && [ -x "$cmd" ] && echo "$cmd" ;;
+ esac
+ done
+fi
+