#!/bin/sh # usage: help - Lists all the available commands # help - Detailled explanation of how "command" works if tty -s then HELPTEXT="Hi $USER, Run 'help' for help, 'help ' for specific help on a command, run 'exit' to exit. Available commands:" else HELPTEXT="Hi $USER, Run 'help' for help, 'help ' 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