#!/usr/bin/env bash

set -x

chmod 0444 *.txt

cp index.html index.html.orig
rm -f ./.index.html
echo -e "<!DOCTYPE html\n" > index.html
echo -e "<html><body>\n\n" >> index.html
echo -e "<head><title>Directory of $(basename $PWD)</title></head>\n\n" >> index.html

for i in (ls -1 * | egrep -v '(html|bash)$ | tail -n +2')
  do echo -e "<a href=\"$i\" target=\"_blank\">\"$i\"</a><br /><br />\n" >> index.html
done  

echo -e "</body></html>\n\n" >> index.html

chmod 0644 index.html

exit 0
