Created
June 2, 2016 22:31
-
-
Save HeLiBloks/94ad2f2ddca7df249ab817b02bd3e409 to your computer and use it in GitHub Desktop.
generate a Thesaurus for bash commands and their corresponding flags.
This file contains hidden or 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/bash | |
# File : bashthesaurus.sh | |
# Author : Henrik Lindgren | |
# Description : create a thesaurus like a teeRex | |
# Last Modified : 2016-06-03 | |
tempfile=/tmp/binFiles | |
mkShellThesaurus(){ | |
#NOTE: this function will wreck havoc if invoked so dont waste your time. | |
#TODO: make this script less tyranic | |
find /usr/local/bin/ /bin/ -type f | sort | uniq | grep -oE '[^ /]+$' > "$tempfile" | |
[ -f ./teeRexSaurius ] && mv teeRexSaurius teeRexSaurius.bak | |
while read -r file ;do | |
echo -n "$file" >> ./teeRexSaurius | |
echo -n "$(man "$file" | grep -oE '^\s+[-][-]?[^, ]*' |tr '\n' ' ')" >> ./teeRexSaurius | |
if [ $? -eq 0 ]; then | |
echo -n "$("$file" --help | grep -oE '^\s+[-][-]?[^, ]*' |tr '\n' ' ')" >> ./teeRexSaurius | |
fi | |
#add EOL | |
echo ' '>> ./teeRexSaurius | |
done < "$tempfile" | |
sed -ir 's/\s\+/ /g' ./teeRexSaurius | |
sed -ri 's/^\s*$//g' ./teeRexSaurius | |
} | |
# vim: set ts=4 sw=4 tw=0 foldenable foldmethod=syntax foldlevel=0 : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment