Skip to content

Instantly share code, notes, and snippets.

@crashbell
Last active April 21, 2022 05:52
Show Gist options
  • Save crashbell/c282e2a865cb615b200e1adc56e1989f to your computer and use it in GitHub Desktop.
Save crashbell/c282e2a865cb615b200e1adc56e1989f to your computer and use it in GitHub Desktop.

Revisions

  1. crashbell revised this gist May 6, 2017. No changes.
  2. crashbell revised this gist May 6, 2017. No changes.
  3. crashbell revised this gist May 6, 2017. No changes.
  4. crashbell created this gist May 6, 2017.
    27 changes: 27 additions & 0 deletions cfg-install.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    rm -rf $HOME/.cfg
    git clone --bare [email protected]:crashbell/dotfiles.git $HOME/.cfg
    function config {
    /usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
    }

    move_backup () {
    echo "Moving backup files";
    mkdir --parents "$(dirname "$1")";
    mv -f "$1" "$2";
    }

    mkdir -p .config-backup
    config fetch --all
    config checkout
    if [ $? = 0 ]; then
    echo "Checked out config.";
    else
    echo "Backing up pre-existing dot files.";
    config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} sh -c 'mkdir -pv $(dirname .config-backup/{})'
    config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv -f {} .config-backup/{}
    echo "Done backup";
    fi;

    config checkout
    config config status.showUntrackedFiles no
    echo "Installation has been completed";