deadc0de6 / dotdrop

Save your dotfiles once, deploy them everywhere
https://dotdrop.readthedocs.io
GNU General Public License v3.0
1.79k stars 106 forks source link

[help] Help with nested directories with link: link_children #176

Closed parker789 closed 5 years ago

parker789 commented 5 years ago

What I am trying to achieve I'm trying to link my entire ~/.config directory at once with link_children, so that when calling dotdrop install only those files which are present inside my dotpath get symlinked, and don't alter any other files within ~/.config

What I have tried so far After running dotdrop import -l link_children ~/.config I get the following directory structure within my dotpath:

/Users/me/dotfiles/dotfiles/.config
├── alacritty
│   └── alacritty.yml
├── bat
│   ├── config
│   └── themes
├── coc
│   ├── commands
│   ├── extensions
│   ├── history.json
│   ├── lists
│   ├── memos.json
│   ├── mru
│   └── ultisnips
├── configstore
│   ├── nodemon.json
│   ├── update-notifier-nodemon.json
│   └── update-notifier-npm.json
├── dotdrop
├── neofetch
│   └── config.conf
└── nvim
    ├── autoload
    ├── coc-settings.json
    ├── init.vim
    ├── plugged
    └── plugins.vim

Now.. I dont wan't a few folders handled by dotpath, so I remove them.. cd ~/dotfiles/dotfiles/.config && rm -rf coc configstore dotdrop nvim/autoload nvim/plugged. Now I have this dir:

├── alacritty
│   └── alacritty.yml
├── bat
│   ├── config
│   └── themes
├── neofetch
│   └── config.conf
└── nvim
    ├── coc-settings.json
    ├── init.vim
    └── plugins.vim

Looks good! These are the files I want managed by dotdrop, so now I run dotdrop install which causes all the subdirectories to be symlinked:

/Users/me/.config
├── alacritty -> /Users/zkrh9u3/dotfiles/dotfiles/.config/alacritty
├── bat -> /Users/zkrh9u3/dotfiles/dotfiles/.config/bat
├── coc
│   ├── commands
│   ├── extensions
│   ├── history.json
│   ├── lists
│   ├── memos.json
│   ├── mru
│   └── ultisnips
├── configstore
│   ├── nodemon.json
│   ├── update-notifier-nodemon.json
│   └── update-notifier-npm.json
├── dotdrop
├── neofetch -> /Users/zkrh9u3/dotfiles/dotfiles/.config/neofetch
└── nvim -> /Users/zkrh9u3/dotfiles/dotfiles/.config/nvim

At this point the subdirectories are symlinked and my original .config files have been overwritten. nvim/autoload and nvim/plugged have been removed from ~/.config because they don't exist within the dotpath. Also, when I re-install the correct files within autoload/plugged, they are automatically added back into the dotpath folder. For now I've moved away from this entire .config link_children approach and am linking each subdirectory individually (d_alacritty, d_bat, d_neofetch, d_nvim).. which works, but I was j/w if this was possible.

deadc0de6 commented 5 years ago

This should work, what version of dotdrop are you using and which installation method do you use (submodule, pypi, etc)?

Here's what I tried with dotdrop latest version from git master:

$ tree /tmp/config
/tmp/config
├── dir1
│   └── a
├── dir2
│   └── b
├── file
└── newfile
$ ./dotdrop.sh import -l link_children /tmp/config
$ rm dotfiles/tmp/config/newfile
$ rm -r dotfiles/tmp/config/dir2
$ ./dotdrop.sh install
$ tree /tmp/config
/tmp/config
├── dir1 -> /home/user/dotdrop/dotfiles/tmp/config/dir1
├── dir2
│   └── b
├── file -> /home/user/dotdrop/dotfiles/tmp/config/file
└── newfile

The config file for reference:

dotfiles:
  d_config:
    src: tmp/config
    dst: /tmp/config
    link: link_children
profiles:
  qube:
    dotfiles:
    - d_config
config:
  backup: true
  link_on_import: nolink
  dotpath: dotfiles
  longkey: false
  create: true
  banner: true
  link_dotfile_default: nolink
  keepdot: false

Moreover dotdrop should ask you before erasing any file, something like this:

Remove "/tmp/config/file" for link creation? [y/N] ? y
    -> linked /tmp/config/file to /home/user/dotdrop/dotfiles/tmp/config/file
Remove "/tmp/config/dir1" for link creation? [y/N] ? y
    -> linked /tmp/config/dir1 to /home/user/dotdrop/dotfiles/tmp/config/dir1
deadc0de6 commented 5 years ago

oh sorry I misread your explanation, your issue is on the nvim subdir ....

deadc0de6 commented 5 years ago

Actually link_children will only link direct children of the dotfile, not recursively. Since nvim is a child of ~/.config it will link it to dotdrop and therefore removing the original ~/.config/nvim.

Yes one solution is to manage each subdirs separately. BTW link_children was initially done for vim: https://github.com/deadc0de6/dotdrop/wiki/symlinked-dotfiles

Any specific behavior you were actually expecting?

parker789 commented 5 years ago

yeah, right now i'm using link_children for ~/.config/nvim and it's working as expected. I was just trying to condense my config.yaml down to 1 item for all my entire config directory. It's not a bad thing to split everything out into their own apps though. I'm pretty sure you answered my question!