andsens / homeshick

git dotfiles synchronizer written in bash
MIT License
2.11k stars 145 forks source link

Unlink deleted files #28

Open andsens opened 11 years ago

andsens commented 11 years ago

Homeshick has a check which determines whether the user should be asked about symlinking newly added files.

Similarly we could add an unlink command which removes symlinks to deleted files.

jrhorn424 commented 11 years ago

+1. I'm not sure of etiquette here. Is hitting "watch thread" enough to register my interest, or does the +1 help?

NemesisRE commented 10 years ago

Since this is still an issue how about something like this in the symlink command:

for deadlink in $(find -xtype l -exec ls -1 {} \;); do
   if [ $(readlink $deadlink | grep ${repo}/home) ]; then
      pending 'deadlink' "$filename"
      rm $deadlink && success || err $EX_ERR "Could not delete $deadlink"
   fi
done
andsens commented 10 years ago

That would mean you'd have to enumerate everything in $HOME (think people with a /music folder etc.), I think calling git with --diff-filter=D is the more sensible option here. I'll start working on it soon.

NemesisRE commented 10 years ago

I did much bash scripting the last weeks maybe i was too fixed on finding the solution with bash instead looking into git options.

You are right this is a much better way

untitaker commented 10 years ago

What about removing dead links which symlink to something in a castle?

andsens commented 10 years ago

What about removing dead links which symlink to something in a castle?

As I said above: You'd have to iterate through everything in the home dir. It's just not feasible.

andsens commented 5 years ago

I recently had the issue where I was missing the unlink command, though it should probably be called clean. The following would be able to find all files in home/ that have been deleted since a castles inception: git diff --name-only --diff-filter=D $(git log --reverse --pretty=format:%h | head -n1) -- home