From f37419ca44dab027948dba59af8446556fabacf7 Mon Sep 17 00:00:00 2001 From: Marley Rae Date: Wed, 24 Jan 2024 19:38:31 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Make=20file=20linker=20handle=20(ne?= =?UTF-8?q?sted)=20directories?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/dot.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/script/dot.sh b/script/dot.sh index a29956f..14df995 100755 --- a/script/dot.sh +++ b/script/dot.sh @@ -9,7 +9,7 @@ declare -r DOTFILES_UTILS="https://raw.githubusercontent.com/$GITHUB_REPO/main/s # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -declare dotfiles_dir="$HOME/dotfiles" +declare dotfiles_dir="$HOME/dotfiles" # MUST HAVE NO LEADING SLASH!! declare yes_to_all=false ################################################################################ @@ -241,6 +241,12 @@ link_file() fi if [[ $skip != "true" ]]; then # "false" or empty + + # See if any directories need to be created + if [[ "$dst" =~ '/' ]]; then + mkdir -p "${dst%/*}" + fi + ln -s "$src" "$dst" print_success "Linked $src to $dst" fi @@ -254,8 +260,11 @@ install_dotfiles() local backup_all=false local skip_all=false - for src in $(find -H "$dotfiles_dir" -maxdepth 2 -name "*.symlink" -not -path ".git"); do - dst="$HOME/$(basename "${src%.*}")" + for src in $(find -H "$dotfiles_dir" -maxdepth 5 -name "*.symlink" -not -path ".git"); do + dst="${src%.*}" + dst="${dst#$dotfiles_dir/}" + dst="${dst#*/}" + dst="$HOME/$dst" link_file "$src" "$dst" done }