Update
This commit is contained in:
@@ -6,12 +6,11 @@ exclude_paths=(
|
||||
"! -path */.git*"
|
||||
)
|
||||
|
||||
# Get array of dirs
|
||||
dirs=( $(find $@ -type d ${exclude_paths[@]}) )
|
||||
# Collect directories into array using null-separated output
|
||||
mapfile -d '' dirs < <(find "$@" -type d ${exclude_paths[@]} -print0)
|
||||
|
||||
# Check array for existing index made by 'tree' (rc=0) or nonexistent (rc=2)
|
||||
for i in "${!dirs[@]}"; do
|
||||
# Check for existing index made by 'tree' (rc=0)
|
||||
# or nonexistent (rc=2)
|
||||
grep -qsm1 "Made by 'tree'" "${dirs[i]}/index.html"
|
||||
if [ $? -eq 1 ]; then
|
||||
unset 'dirs[i]'
|
||||
@@ -19,7 +18,7 @@ for i in "${!dirs[@]}"; do
|
||||
done
|
||||
|
||||
# Reset array
|
||||
dirs=( "${dirs[@]}" )
|
||||
dirs=( "${dirs[@]}" )
|
||||
|
||||
# List dirs
|
||||
echo "Index will be created in:"
|
||||
@@ -28,26 +27,29 @@ echo
|
||||
|
||||
# Get confirm for creation of index
|
||||
read -n1 -p "Continue? (y/N) " confirm
|
||||
if ! echo $confirm | grep -q '^[Yy]$'; then
|
||||
echo -e "\nAborting"; exit 1
|
||||
if ! echo "$confirm" | grep -q '^[Yy]$'; then
|
||||
echo -e "\nAborting!"; exit 1
|
||||
fi
|
||||
echo
|
||||
|
||||
# Create the indexes
|
||||
for i in "${!dirs[@]}"; do
|
||||
cd "${dirs[i]}"
|
||||
echo "Creating index in ${dirs[i]}"
|
||||
# Generate HTML index - Color, Date, Size(h), No lines(i), Title(T), filter self(I)
|
||||
# Pipe to sed: Remove credits, link to parent dir, change colours
|
||||
tree -CDhi -H "." -T "$(basename $PWD)" -I "index.html" -L 1\
|
||||
--dirsfirst --charset "utf-8"\
|
||||
| sed\
|
||||
-e '/<hr>/,+7d' -e 's/href="\.">\./href="..">../'\
|
||||
-e 's/BODY {/BODY { color: lime; background: black;/'\
|
||||
-e 's/color: black;/color: lime;/'\
|
||||
-e 's/color: blue;/color: deepskyblue;/'\
|
||||
-e 's/color: green;/color: limegreen;/'\
|
||||
-e 's/color: purple;/color: mediumpurple;/'\
|
||||
> index.html
|
||||
cd $OLDPWD
|
||||
for dir in "${dirs[@]}"; do
|
||||
echo "Creating index in $dir"
|
||||
(
|
||||
cd "$dir" || exit 1
|
||||
|
||||
# Generate HTML index - Color, Date, Size(h), No lines(i), Title(T), filter self(I)
|
||||
# Pipe to sed: Remove credits, link to parent dir, change colours
|
||||
tree -CDhi -H "." -T "$(basename "$PWD")" -I "index.html" -L 1 \
|
||||
--dirsfirst --charset "utf-8" \
|
||||
| sed \
|
||||
-e '/<hr>/,+7d' \
|
||||
-e 's/href="\.">\./href="..">../' \
|
||||
-e 's/BODY {/BODY { color: lime; background: black;/' \
|
||||
-e 's/color: black;/color: lime;/' \
|
||||
-e 's/color: blue;/color: deepskyblue;/' \
|
||||
-e 's/color: green;/color: limegreen;/' \
|
||||
-e 's/color: purple;/color: mediumpurple;/' \
|
||||
> index.html
|
||||
)
|
||||
done
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
@echo off
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
set PID=%~1
|
||||
set INTERVAL=1
|
||||
SET "MEMORY="
|
||||
|
||||
echo "Timestamp","Memory Usage (KB)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user