Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stow-like recursive symlinking #82

Closed
eddiezane opened this issue Apr 29, 2021 · 8 comments
Closed

Stow-like recursive symlinking #82

eddiezane opened this issue Apr 29, 2021 · 8 comments

Comments

@eddiezane
Copy link

eddiezane commented Apr 29, 2021

Given this directory, with stow I can run stow nvim from the root of my dot files repo to recursively symlink all the files resulting in ~/.config/nvim/{coc-config.vim,coc-settings.json,init.vim} existing.

I see that file.symlink was implemented (side note: looks like it didn't make the readme yet. I can PR that.). Would this behavior be more aligned to a directory.link? Or maybe an option on the directory.copy action?

@eddiezane eddiezane changed the title Stow like recursive symlinking Stow-like recursive symlinking Apr 29, 2021
@rawkode
Copy link
Member

rawkode commented Apr 29, 2021

This is a great question. The reason it didn't make directory.copy is because I wasn't sure if that action would handle any templating or not and symlinks can't be templated / rendered.

A directory.link would be a welcomed changed.

Side note: yeah, docs are missing a few things. We're currently working on migrating them from mdBook to GitBook. Won't be long 😃

@eddiezane
Copy link
Author

I'll try and whip something up this weekend! Rust has been near the top of my list to learn for a bit now.

@rawkode
Copy link
Member

rawkode commented May 14, 2021

@eddiezane file.link will work for this use case now. It doesn’t matter if the to param is a file or directory, it creates the link either way.

Docs still need updated since the big atom refactor, but adding your own actions is a lot simpler now.

@eddiezane
Copy link
Author

Stellar! I've slowly been making my way through the Rust book. Haven't been scared away yet 😅.

@rawkode
Copy link
Member

rawkode commented May 17, 2021

Closing this just now, as I beleive file.link handles this. Please feel free to open this again if I am wrong and I'll get it sorted

@rawkode rawkode closed this as completed May 17, 2021
@eddiezane
Copy link
Author

Ah sorry I misunderstood your previous comment.

Thank you!

@eddiezane
Copy link
Author

Had a chance to test this.

file.link does work for linking an entire directory but isn't quite what I was looking for.

Stow will recursively walk a directory and link files individually.

Take my neovim config for example:

 ~/.dotfiles[main ☂ ] tree -a nvim
nvim
└── .config
    └── nvim
        ├── coc-config.vim
        ├── coc-settings.json
        └── init.vim

Running stow nvim will keep the directory structure and individually link the files using $HOME as the root by default.

 ~/.dotfiles[main ☂ ] ls -la ~/.config/nvim
total 0
drwxr-xr-x   7 ezaneski  staff  224 Feb  8 16:36 .
drwxr-xr-x  16 ezaneski  staff  512 Feb 23 18:45 ..
drwxr-xr-x   4 ezaneski  staff  128 Apr 30 09:56 autoload
lrwxr-xr-x   1 ezaneski  staff   48 Oct 19  2020 coc-config.vim -> ../../.dotfiles/nvim/.config/nvim/coc-config.vim
lrwxr-xr-x   1 ezaneski  staff   51 Oct 19  2020 coc-settings.json -> ../../.dotfiles/nvim/.config/nvim/coc-settings.json
lrwxr-xr-x   1 ezaneski  staff   42 May 14  2020 init.vim -> ../../.dotfiles/nvim/.config/nvim/init.vim
drwxr-xr-x  23 ezaneski  staff  736 May  5 12:05 plugged

This allows for encapsulating different programs into folders - sort of like a deb package would do. Based on the path in the folder I can see that .dotfiles/nvim/.config/nvim/init.vim should live under $HOME/.config/nvim.

I'd like to replicate the same behavior (doesn't have to be directory.link):

actions:
- action: directory.link
  from: $HOME/.dotfiles/nvim
  to: $HOME

This could be manually accomplished with individual file links but an action would simplify it. The answer could also be this is an anti-pattern for comtrya and to keep using stow 😅. I'm realizing that this setup offloads the configuration to the directory structure.

@rawkode rawkode reopened this Jun 22, 2021
@rawkode rawkode self-assigned this Mar 4, 2022
@rawkode rawkode added this to the v0.8.0 milestone Mar 4, 2022
@rawkode
Copy link
Member

rawkode commented Mar 4, 2022

@eddiezane I've "maybe" implemented this in #139

Can you maybe test it and see if the behaviour matches up with what you expected?

It doesn't do recursive, as I wasn't sure creating the directories to then symlink inside made any sense beyond just symlinking the directories too.

Lemme know 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants