aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfix-dotfile-paths.sh25
1 files changed, 14 insertions, 11 deletions
diff --git a/fix-dotfile-paths.sh b/fix-dotfile-paths.sh
index 43a2fc8..8894a7e 100755
--- a/fix-dotfile-paths.sh
+++ b/fix-dotfile-paths.sh
@@ -7,21 +7,24 @@ create_ls_entry () {
if [ "$1" != "" ]; then
echo "- [[$2$1..][=../=]]" >> index.org
fi
- find -L -- . -maxdepth 1 -type d | sed '/^\.$/d' | sed 's/^\.\///' | while read -r dir; do
+ find -L -- . -maxdepth 1 -type d | sed '/^\.$/d' | sed 's/^\.\///' | sort | while read -r dir; do
if [ "$dir" != "*" ] && [ "$dir" != ".git" ]; then
echo "- [[$2$1$dir][=$dir/=]]" >> index.org
fi
done
- echo "* Files" >> index.org
- find -L -- . -maxdepth 1 -type f | sed 's/^\.\///' | while read -r file; do
- if [ "$file" = ".wallpaper" ]; then
- echo "- [[https://wallhaven.cc/w/vgryy5][=.wallpaper=]]" >> index.org
- elif echo "$file" | grep -q "\.org$" && [ "$file" != "index.org" ]; then
- new_file=$(basename "$(grep '#+begin_src' "$file" | head -1 | cut -d ' ' -f 4)")
- html=$(echo "$file" | sed 's/\.org$/\.html/')
- echo "- [[$2$1$html][=$new_file=]]" >> index.org
- fi
- done
+ files=$(find -L -- . -maxdepth 1 -type f | sed 's/^\.\///')
+ if [ "$(echo "$files" | wc -l | sed 's/[ \t]*//g')" != 0 ]; then
+ echo '* Files' >> index.org
+ echo "$files" | sort | while read -r file; do
+ if [ "$file" = ".wallpaper" ]; then
+ echo "- [[https://wallhaven.cc/w/vgryy5][=.wallpaper=]]" >> index.org
+ elif echo "$file" | grep -q "\.org$" && [ "$file" != "index.org" ]; then
+ new_file=$(basename "$(grep '#+begin_src' "$file" | head -1 | cut -d ' ' -f 4)")
+ html=$(echo "$file" | sed 's/\.org$/\.html/')
+ echo "- [[$2$1$html][=$new_file=]]" >> index.org
+ fi
+ done
+ fi
}
create_dir_tree () {