fishyindex/fishyindex

34 lines
935 B
Fish
Executable File

#!/usr/bin/fish
function mkindex
set DIR $argv[1]
set FILE $DIR/index.html
echo "<html><head><title>Index of $DIR</title></head><body style=\"font-family: monospace;\">" > $FILE
echo "<h1>Index of $DIR</h1><hr>" >> $FILE
printf '<p>Generated on %s\n</p>' (date) >> $FILE
echo "<table>" >> $FILE
echo "<thead><tr><th>Name</th><th>Last Modified</th></tr></thead><tbody>" >> $FILE
for f in $DIR/*
set FILENAME (basename $f)
if test -d $f
set FILENAME "$FILENAME/"
end
set TIMESTAMP (date -r $f)
echo "<tr><td><a href=\"$FILENAME\">$FILENAME</a></td><td><span style=\"color: #888;\">$TIMESTAMP</span></td></tr>" >> $FILE
end
echo "</tbody></table></body></html>" >> $FILE
end
function index-for-all
set DIR $argv[1]
mkindex $DIR
for d in $DIR/*
if test -d $d
index-for-all $d
end
end
end
index-for-all (pwd)