#!/bin/bash

declare _home="/Users/admin"
declare _repos="/Users/admin/sandbox/dotfiles"

function _is_excluded() {
    [[ $1 == *~
            || $1 == .*cache*
            || $1 == .*history*
            || $1 == .CFUserTextEncoding
            || $1 == .DS_Store
            || $1 == .ICEauthority
            || $1 == .MacOSX
            || $1 == .Trash
            || $1 == .Xauthority
            || $1 == .cabal
            || $1 == .cpan
            || $1 == .dbus
            || $1 == .dvdcss
            || $1 == .easytag
            || $1 == .elisp
            || $1 == .emacs.d
            || $1 == .eshell
            || $1 == .firefox
            || $1 == .fontconfig*
            || $1 == .gconf*
            || $1 == .gnome2*
            || $1 == .gnupg
            || $1 == .htpasswd
            || $1 == .ido.last*
            || $1 == .jungledisk*
            || $1 == .kde
            || $1 == .localized
            || $1 == .mozilla
            || $1 == .mplayer
            || $1 == .navi2ch
            || $1 == .nh-todo
            || $1 == .pan
            || $1 == .projects.ede
            || $1 == .recently-used*
            || $1 == .rnd
            || $1 == .skk-*
            || $1 == .ssh
            || $1 == .tome
            || $1 == .trackballs
            || $1 == .uim.d
            || $1 == .unison
            || $1 == .viminfo
            || $1 == .w3m
            || $1 == .xchat2*
            || $1 == .zcomp*
            || $1 == .zfunc
            ]]
}

function _is_symlink() {
    [[ -h $1 ]]
}

function _main() {
    local _current=$(ls -d .* | egrep -v '^\.\.?$')
    local i
    
    echo "Unregistered dotfiles:"
    for i in $_current; do
        _is_excluded $i && continue
        _is_symlink $i  && continue

        echo $i
    done

    echo "darcs repos:"
    cd $_repos
    darcs whatsnew -sl
}

cd $_home
_main
