aboutsummaryrefslogtreecommitdiff
path: root/fix-dotfile-paths.sh
diff options
context:
space:
mode:
Diffstat (limited to 'fix-dotfile-paths.sh')
-rwxr-xr-xfix-dotfile-paths.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/fix-dotfile-paths.sh b/fix-dotfile-paths.sh
new file mode 100755
index 0000000..b3b0a44
--- /dev/null
+++ b/fix-dotfile-paths.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+START=$(pwd)
+find -- . -type d | sed '/^\.\$/d' | sed '/^\.\/\.git\//d' | sed '/^\.\/.git/d' | while read -r line; do
+ cd "${line}" || 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 "- [[/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
+ cd "${START}" || exit
+done