dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Stupid question

Open ElModdy opened this issue 5 years ago • 1 comments

Hi, I'm new to Stow and I'm having difficulties understanding how to manage the dotfiles properly. My quest is: If you have to add a file, do you create it in the repo and then relaunch stow every time? I know my question is off topic and I will remove it if you don't want to answare me but I really appreciate any kind of help.

ElModdy avatar Apr 15 '19 09:04 ElModdy

hey, no worries.

stow is an on demand tool. when you run the command it looks in the specified directory for files then symlinks them into the target location. if you edit one of the source files already linked the changes are immediate. but if you create a new file the symlinks are not created yet until you run stow (again).

hope that helps! i wrote a blog post about my workflow that includes a number of stow examples.

ok, here's a little example i cooked up for ya:

this is our tree of dotfiles and a /etc skeleton directory:

 ___╱╲  _____ ╱╲______ ____╱╲   ___╱╲
 ╲ _  ╲╱  .:╱╱.:╲____╱╱_╲_.  ╲ ╱.╱__ ╲
  ╲╲  ╱    ╱╱    ___╱╱  .╲╱ _╱╱ ╲  ╱  ╲
  ╱.: ╲    ╲_.     ╱╱    _. ╲╱ .:╲╱   ╱
 ╱____╱╲  __╲╱__  ╱╱______│ ╱╲_______╱
        ╲╱      ╲╱        │╱x0^67^iMP!

[~]━━ ━ cd /tmp/test
[/tmp/test]━━ ━ tree .
.
├── dotfiles/
│   ├── cron/
│   │   └── etc/
│   │       └── cron.d/
│   │           ├── daily
│   │           ├── monthly
│   │           ├── weekly
│   │           └── yearly
│   └── motd/
│       └── etc/
│           └── motd.txt
└── etc/
    └── cron.d/

8 directories, 5 files

enter the dotfiles directory, stow the motd file and look at the results:

[/tmp/test]━━ ━ cd dotfiles
[/tmp/test/dotfiles]━━ ━ stow motd
[/tmp/test/dotfiles]━━ ━ tree ../
../
├── dotfiles/
│   ├── cron/
│   │   └── etc/
│   │       └── cron.d/
│   │           ├── daily
│   │           ├── monthly
│   │           ├── weekly
│   │           └── yearly
│   └── motd/
│       └── etc/
│           └── motd.txt
└── etc/
    ├── cron.d/
    └── motd.txt -> ../dotfiles/motd/etc/motd.txt

8 directories, 6 files

repeat the process with the cron directory:

[/tmp/test/dotfiles]━━ ━ stow cron
[/tmp/test/dotfiles]━━ ━ tree ../
../
├── dotfiles/
│   ├── cron/
│   │   └── etc/
│   │       └── cron.d/
│   │           ├── daily
│   │           ├── monthly
│   │           ├── weekly
│   │           └── yearly
│   └── motd/
│       └── etc/
│           └── motd.txt
└── etc/
    ├── cron.d/
    │   ├── daily -> ../../dotfiles/cron/etc/cron.d/daily
    │   ├── monthly -> ../../dotfiles/cron/etc/cron.d/monthly
    │   ├── weekly -> ../../dotfiles/cron/etc/cron.d/weekly
    │   └── yearly -> ../../dotfiles/cron/etc/cron.d/yearly
    └── motd.txt -> ../dotfiles/motd/etc/motd.txt

8 directories, 10 files

create a new file in the cron directory and notice the /etc tree is unaffected:

[/tmp/test/dotfiles]━━ ━ touch cron/etc/cron.d/hourly
[/tmp/test/dotfiles]━━ ━ tree ../
../
├── dotfiles/
│   ├── cron/
│   │   └── etc/
│   │       └── cron.d/
│   │           ├── daily
│   │           ├── hourly
│   │           ├── monthly
│   │           ├── weekly
│   │           └── yearly
│   └── motd/
│       └── etc/
│           └── motd.txt
└── etc/
    ├── cron.d/
    │   ├── daily -> ../../dotfiles/cron/etc/cron.d/daily
    │   ├── monthly -> ../../dotfiles/cron/etc/cron.d/monthly
    │   ├── weekly -> ../../dotfiles/cron/etc/cron.d/weekly
    │   └── yearly -> ../../dotfiles/cron/etc/cron.d/yearly
    └── motd.txt -> ../dotfiles/motd/etc/motd.txt

8 directories, 11 files

run stow again, and the new file is linked into place:

[/tmp/test/dotfiles]━━ ━ stow cron
[/tmp/test/dotfiles]━━ ━ tree ../
../
├── dotfiles/
│   ├── cron/
│   │   └── etc/
│   │       └── cron.d/
│   │           ├── daily
│   │           ├── hourly
│   │           ├── monthly
│   │           ├── weekly
│   │           └── yearly
│   └── motd/
│       └── etc/
│           └── motd.txt
└── etc/
    ├── cron.d/
    │   ├── daily -> ../../dotfiles/cron/etc/cron.d/daily
    │   ├── hourly -> ../../dotfiles/cron/etc/cron.d/hourly
    │   ├── monthly -> ../../dotfiles/cron/etc/cron.d/monthly
    │   ├── weekly -> ../../dotfiles/cron/etc/cron.d/weekly
    │   └── yearly -> ../../dotfiles/cron/etc/cron.d/yearly
    └── motd.txt -> ../dotfiles/motd/etc/motd.txt

8 directories, 12 files

xero avatar Apr 16 '19 14:04 xero