andsens / homeshick

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

diff sub command #84

Open aarcro opened 10 years ago

aarcro commented 10 years ago

homeshick diff <castle> [<file1> <file2>]

Should diff the current files against the ones in the castle. useful before linking to know what's getting clobbered or should be merged in.

andsens commented 10 years ago

Hm, interesting feature. That'd be quite useful. The file arguments would be relative to $HOME right?

What should the syntax of the output look like? Just like link or more like git status?

p.s.: What's a "homestick" :-)

aarcro commented 10 years ago

I was thinking diff -u for the output. I've also found that on one host I need a different .gitconfig, so I don't link it, but do a vimdiff when there are changes in the castle to merge in.

Maybe a DIFFTOOL env variable and/or --difftool='' flag would be useful.

andsens commented 10 years ago

I was thinking diff -u for the output

Hm, ok. I thought you meant that homeshick should show what was going to be symlinked and which files would conflict. I don't think it falls into the purview of homeshick to do such a fine-grained diff like you are suggesting. It'd be nice to somehow be able to integrate homeshick with a git alias though and through that obtain your suggested feature. To do that #70 ("make homeshick output machine readable") needs to be fixed first, then you could write all kinds of cool little scripts that combine homeshick and git features.

I've also found that on one host I need a different .gitconfig

Did you know you can do this now?

[include]
    path = ~/.gitconfig-local

That's a rather handy feature they introduced.

aarcro commented 10 years ago

Thanks for the tip on gitconfig-local. Already doing _local's with .bashrc and .vimrc.

Homeshick already prompts to replace existing files with symlinks. But I never want to just say yes, I want to compare the files so I know what i'm losing if anything. Right now I frequently do homeshick cd dotfiles; diff -u home/.bashrc ~/.bashrc

So I figured homeshick diff dotfiles home/.bashrc could save some keystrokes.

I don't think git helps, since it's diffing a file in the repo to a static file outside of version control.

If you think it's out of scope though, go ahead and close this.

andsens commented 10 years ago

Ah, ok. So additionally to the [yN] options, you'd like a [d] option that opens up diff -u and compares the file in $HOME with the file in the repo. That is definitely in scope.
I'll have a look at it and see how it could be implemented, should be straightforward (though I think the prompting tool may need a rewrite).

aarcro commented 10 years ago

That would be awesome! If it picked up an environment variable for the actual diff command that would be even better. I can take a look at the implementation as well.