aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfix-dotfile-paths.sh51
1 files changed, 32 insertions, 19 deletions
diff --git a/fix-dotfile-paths.sh b/fix-dotfile-paths.sh
index 124c7ad..fcabd6f 100755
--- a/fix-dotfile-paths.sh
+++ b/fix-dotfile-paths.sh
@@ -6,36 +6,49 @@ create_ls_entry () {
if [ "$1" != "" ]; then
echo "- [[https://jjanzen.ca/dotfiles/$1..][=../=]]" >> index.org
fi
- find -- . -maxdepth 1 -type d | sed '/^\.$/d' | sed 's/^\.\///' | while read -r dir; do
- if [ "${dir}" != "*" ] && [ "${dir}" != ".git" ]; then
- echo "- [[https://jjanzen.ca/dotfiles/$1${dir}][=${dir}/=]]" >> index.org
+ find -L -- . -maxdepth 1 -type d | sed '/^\.$/d' | sed 's/^\.\///' | while read -r dir; do
+ if [ "$dir" != "*" ] && [ "$dir" != ".git" ]; then
+ echo "- [[https://jjanzen.ca/dotfiles/$1$dir][=$dir/=]]" >> index.org
fi
done
echo "* Files" >> index.org
- find -- . -maxdepth 1 -type f | sed 's/^\.\///' | while read -r file; do
- if [ "${file}" = ".wallpaper" ]; then
+ 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 "- [[https://jjanzen.ca/dotfiles/$1${html}][=${new_file}=]]" >> 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 "- [[https://jjanzen.ca/dotfiles/$1$html][=$new_file=]]" >> index.org
fi
done
}
-cd ~/.dotfiles || exit
-git checkout main
-START=$(pwd)
+create_dir_tree () {
+ ROOT="$HOME/.dotfiles/$1"
+ create_ls_entry ""
-create_ls_entry ""
+ # iterate over all directories
+ find -L -- . -type d | sed '/^\.$/d' | while read -r dir; do
+ cd "$dir" || continue
-# 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
+ dir=$(echo "$dir" | sed 's/^\.\///')
- dir=$(echo "${dir}" | sed 's/^\.\///')
+ create_ls_entry "$dir/"
- create_ls_entry "${dir}/"
+ cd "$ROOT" || exit
+ done
+}
- cd "${START}" || exit
+cd ~/.dotfiles || exit
+git checkout main
+echo '#+title: Dotfiles' >> index.org
+echo 'This is my system configuration. Choose which system to browse: ' >> index.org
+find -- . -maxdepth 1 -type d | sed '/\(^\.$\|^\.\/\.git$\|\.\/common\)/d' | while read -r root; do
+ root=$(echo "$root" | sed 's/\(\.\/\|\/$\)//')
+ echo "- [[https://jjanzen.ca/dotfiles/$root][$root]]" >> index.org
+ cd "$root" || exit
+ create_dir_tree "$root"
+ cd ~/.dotfiles || exit
done
+
+cd || exit