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

Ability to unlink #116

Open
adam-beck opened this issue Oct 10, 2014 · 7 comments
Open

Ability to unlink #116

adam-beck opened this issue Oct 10, 2014 · 7 comments

Comments

@adam-beck
Copy link

Homesick offers the ability to remove symlinks:
You can remove symlinks anytime when you don't need them anymore
homesick unlink CASTLE

Would anybody be interested in having the same functionality in this repo?

@andsens
Copy link
Owner

andsens commented Oct 10, 2014

Yes, that would be useful I suppose. It is covered a little by the long-standing #28.
How does homesick know which files to unlink. Does it iterate through the repo home/ dir or through $HOME (looking for symlinks with a specific path) to find the files?

We will not be able to do this with directories of course, since homeshick does not symlink them. Multiple castles may link files into the same folder.

@adam-beck
Copy link
Author

By looking at homesick, it just looks like they iterate through the specified castle's directory (where the actual files are stored; home/) and then finds the path of the symlinks based on HOME.

Unlink Command

Unlink Function

It never removes subdirectories (I don't believe they link directories either) so that wouldn't be an issue.

@absorber
Copy link

👍

I'm still a noob at bash, so I was wondering how to securely unlink files currently?

For example, I have $HOME/.pulse/ which I then linked to /home/.pulse/, but I no longer want that dir to be tracked.
My thinking is to just do homeshick cd mydotfiles and then do git rm -r .pulse/ in order to remove /home/.pulse/ from the git working tree.
Afterwards I can then do something like rsync -avp .pulse/ $HOME/.pulse/.

Would that be the most correct method?

@andsens
Copy link
Owner

andsens commented Dec 10, 2014

Definitely don't delete the .pulse/ dir first otherwise you kill your data! :-)
I'd do this (and this will probably be along the lines of how the unlink command will be implemented, minus the rsync):

cd $HOME
rsync -avp $HOME/.homesick/repos/mydotfiles/home/.pulse/ $HOME/.pulse/
homeshick cd mydotfiles
git rm -rf home/.pulse

Note that the symlinks to the files in the .pulse dir will not be removed on other machines by homeshick (yet).

@absorber
Copy link

Oh thanks! That worked perfectly. Yeah I really need start learning to differentiate between git rm and git rm --cached before that results in some bad decisions :)

@sukima
Copy link

sukima commented Aug 12, 2015

Just ran into this problem. Accidentally installed my homeshick castles on a shared account. Now I need to go through each file one at a time to undo the links.

@sukima
Copy link

sukima commented Aug 12, 2015

This worked… mostly:

homeshick -v link \
  | sed 's/  */ /g;/ignored/d' \
  | cut -d' ' -f 3 \
  # tail -r or tac or sed '1!G;h;$d' depending on your system.
  | tail -r \
  | while read file; do
    if [ -d $file ]; then
      # non empty directories (ones with temp files) are not deleted and
      # display an error for clean up after.
      rmdir $file
    else
      rm $file
    fi
  done

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

No branches or pull requests

4 participants