justone / dfm

dotfiles manager
http://endot.org/projects/#dfm
Other
122 stars 18 forks source link

Add isunclean command #6

Closed nsp closed 11 years ago

nsp commented 11 years ago

etckeeper does this with the following /bin/sh syntax

[ -d .git ] && [ -n "`git ls-files --modified --deleted --others --exclude-standard`" ]
justone commented 11 years ago

What exactly is the intent of this command? Do you have an example use case?

nsp commented 11 years ago

A bad habit I fall into is in leaving config changes uncommitted after they're working, and with an 'isunclean' command I could create a cron job and/or login/logout scripts that check for this situation and return a simple error code that I can work with.

justone commented 11 years ago

Cool, this definitely makes sense. However, I think that this is something that is more of a git feature than a dfm feature. It can be added to your .gitconfig like this:

[alias]
    isunclean = "![ -n \"`git ls-files --modified --deleted --others --exclude-standard`\" ]"

Then, to call it, use the dfm passthrough:

$ if dfm isunclean; then echo 'danger danger!'; fi
danger danger!
nsp commented 11 years ago

You know, I like your way of doing it a lot better, because then I'd have the alias for every other git repo.