diff options
author | Jacob Janzen <jjanzenn@proton.me> | 2024-08-09 22:34:17 -0500 |
---|---|---|
committer | Jacob Janzen <jjanzenn@proton.me> | 2024-08-09 22:34:17 -0500 |
commit | c62274d9cbfde56023b6f690e03164ac09a67095 (patch) | |
tree | c6ef41e2887e6903a5d84e05241606dca30a64c8 /fix-dotfile-paths.sh | |
parent | bb3e2e1cc21044439b27fa4a56edf441f6f16977 (diff) |
follow links
Diffstat (limited to 'fix-dotfile-paths.sh')
-rwxr-xr-x | fix-dotfile-paths.sh | 51 |
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 |