Created
July 12, 2018 08:31
-
-
Save danixland/77bdb5a6228f7aca33f8454e9c43411b to your computer and use it in GitHub Desktop.
Him: Help IMproved - modified version of the help script shipped with git.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment