/dotfiles

Configuration files for my Linux system.

Primary LanguageVim Script

dotfiles

Method & usage:

Sources: this HackerNews comment by StreakyCobra and this tutorial.

Initialize the dotfiles repository.

git init --bare $HOME/.dots
alias dots='/usr/bin/git --git-dir=$HOME/.dots --work-tree=$HOME'
dots config --local status.showUntrackedFiles no

Creates a hidden dotfiles directory in the HOME directory and initializes it as a bare git repository. Here the dotfiles will be backed up. We also tell git to only consider files from now on (this prevents git from adding everything in the home directory to the repository).

Interacting with the repository.

In order to manipulate the repository we need to use the alias we created, for example:

dots add .vimrc
dots commit -m "Added .vimrc"
dots push

All the regular git commands/aliases work with this command. I have this alias in my .bash_aliases file. If you don’t use .bash_aliases, or use a different shell, I suggest adding it to your shell configuration file (replace .bashrc with whatever your shell sources):

echo "alias dots='/usr/bin/git --git-dir=$HOME/.dots --work-tree=$HOME'" >> $HOME/.bashrc

Install the dotfiles.

Installing the dotfiles on a new machine is a bit more complicated. There’s a script included in this repository.

Requires GNU Parallel (should be in your distribution repository if you use Linux).

Script installation:

git clone https://github.com/micholczyk/dotfiles $HOME/dots_tmp
chmod +x $HOME/dots_tmp/dotfiles-install.sh
./$HOME/dots_tmp/dotfiles-install.sh && rm -rf $HOME/dots_tmp

Manual installation:

# clone the repository
git clone --bare https://github.com/micholczyk/dotfiles $HOME/.dots
alias dots='/usr/bin/git --git-dir=$HOME/.dots --work-tree=$HOME'
cd $HOME
echo ".dots" > .gitignore # avoid weird recursion problems
dots checkout # this might fail

If the checkout fails you have some files overlapping with my dotfiles, in this case back them up and remove (move to another directory):

mkdir -p .dots_backup
dots checkout 2>&1 | cut -d" " -f 1 | tail -n +2 | head -n -2 | awk {'print $1'} | parallel 'mkdir -p $HOME/.dots_backup/{}; mv {} $HOME/.dots_backup/{}'

Then run checkout again and finish the installation by setting the showUntrackedFiles flag.

dots checkout
dots config --local status.showUntrackedFiles no

You should be able to manipulate with the repository as described and the dotfiles should be installed now.