aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfix-dotfile-paths.sh56
1 files changed, 35 insertions, 21 deletions
diff --git a/fix-dotfile-paths.sh b/fix-dotfile-paths.sh
index aa0c6f1..d2daece 100755
--- a/fix-dotfile-paths.sh
+++ b/fix-dotfile-paths.sh
@@ -1,30 +1,44 @@
#!/bin/sh
+create_ls_entry () {
+ echo "#+title: =~/$1=" > index.org
+ echo "* Directories" >> index.org
+ for dir in */; do
+ echo "- [[https://jjanzen.ca/dotfiles/$1/${dir}][${dir}]]" >> index.org
+ done
+ echo "* Files" >> index.org
+ find -- . -maxdepth 1 -type f | sed 's/^\.\///' | while read -r file; do
+ if test -f "${file}"; then
+ if [ "${file}" = "*" ] || [ "${file}" = "index.org" ] || [ "${file}" = "README.md" ] || [ "${file}" = "LICENSE" ] || [ "${file}" = ".build.yml" ]; then
+ continue
+ elif [ "${file}" = ".wallpaper" ]; then
+ echo "- [[https://wallhaven.cc/w/vgryy5][.wallpaper]]" >> index.org
+ continue
+ fi
+
+ if echo "${file}" | grep -q "\.org\$"; then
+ new_file=$(basename "$(grep '#+begin_src' "${file}" | head -1 | cut -d ' ' -f 4)")
+ fi
+ if [ "$new_file" = "" ]; then
+ new_file=$file
+ fi
+ echo "- [[https://jjanzen.ca/dotfiles/$1/${file}][${new_file}]]" >> index.org
+ fi
+ done
+}
+
cd ~/.dotfiles || exit
START=$(pwd)
-find -- . -type d | sed '/^\.\$/d' | sed '/^\.\/\.git\//d' | sed '/^\.\/.git/d' | while read -r line; do
- cd "${line}" || continue
+
+create_ls_entry ""
+
+# iterate over all files except the .git/ directory and .
+find -- . -type d | sed '/^\.\$/d' | sed '/^\.\/\.git\//d' | sed '/^\.\/.git/d' | while read -r dir; do
+ cd "${dir}" || continue
line=$(echo "${line}" | sed 's/^\.\///')
- if ! test -f ./index.org; then
- echo "#+title: =~/${line}=" > index.org
- echo "* Directories" >> index.org
- for dir in */; do
- echo "- [[https://jjanzen.ca/dotfiles/${line}/${dir}][${dir}]]" >> index.org
- done
- echo "* Files" >> index.org
- for file in *; do
- if test -f "${file}"; then
- if echo "${file}" | grep -q "\.org\$"; then
- new_file=$(basename "$(grep '#+begin_src' "${file}" | head -1 | cut -d ' ' -f 4)")
- fi
- if [ "$new_file" = "" ]; then
- new_file=$file
- fi
- echo "- [[/dotfiles/${line}/${file}][${new_file}]]" >> index.org
- fi
- done
- fi
+ create_ls_entry "${dir}"
+
cd "${START}" || exit
done