There's no place like ~ !
Switch branches/tags
Clone or download
Latest commit ed8f312 Oct 13, 2018
Permalink
Failed to load latest commit information.
.bin Git: Fix pretty formats Oct 14, 2018
.config Awesome: Move client related keybindings Oct 13, 2018
.irssi Irssi: Add irssi config Dec 11, 2017
.mpd Mpd: Add mpd config Dec 9, 2017
.ncmpcpp Ncmpcpp: Add ncmpcpp config Dec 9, 2017
.pkglist Pkgbuild: Update pkgbuilds and pkglists Oct 4, 2018
.startpage Firefox: Add firefox config Feb 28, 2018
.vim Vim: Clean up configs, restructure Oct 13, 2018
packages Fontconfig: Add config Oct 6, 2018
pictures Git: Update readme, fix branch alias May 31, 2018
projects Git: Update submodules Jul 30, 2018
.Xresources Zsh: Fix completion colors, remove .bin from PATH Feb 1, 2018
.bash_profile Sh: Fix profile setup, formatting Mar 14, 2018
.bashrc Bash: Restructure configs Oct 13, 2018
.dialogrc Dialog: Add dialogrc Dec 9, 2017
.dircolors Zsh: Update completion, prompt, add submodules Mar 20, 2018
.dircolors.old Sh: Fix profile setup, formatting Mar 14, 2018
.gitattributes Dotfiles: Use dotfiles.sh by Eli Schwartz Feb 8, 2018
.gitconfig Git: Fix pretty formats Oct 14, 2018
.gitignore Git: Set diff algorithm, update gitignore Sep 24, 2018
.gitmodules Zsh: Enhance configs, restructure Oct 13, 2018
.ignore Git: Adjust settings, add ignores Oct 1, 2018
.inputrc Readline: Add options Oct 4, 2018
.lesskey Less: Add keybinding to un-highlight May 9, 2018
.profile Zsh: Update prompt, add/fix aliases Jul 30, 2018
.psqlrc Psql: Add psqlrc Dec 9, 2017
.tmux.conf Tmux: Add copy-mode pane navigation bindings Oct 8, 2018
.tmux.minimal.conf Tmux: Add copy-mode pane navigation bindings Oct 8, 2018
.vimrc Vim: Clean up configs, restructure Oct 13, 2018
.xinitrc Xorg: Update path to script Jun 14, 2018
.zprofile Sh: Fix profile setup, formatting Mar 14, 2018
.zshrc Zsh: Enhance configs, restructure Oct 13, 2018
LICENSE Git: Add license Dec 7, 2017
README.md Git: Update install scripts Jun 21, 2018

README.md

.dotfiles

There's no place like ~ !



Table of Contents

Screenshots

Awesome WM Awesome WM Awesome WM

Introduction

This repository contains my personal configuration files (also known as dotfiles). The package lists can be found in ~/.pkglist/. To install all official packages, you can use for example cat .pkglist/pacman | pacman -S -.

In the following sections I'll explain how this dotfiles repository was set up, how to use it and how to restore them, for example on a new device.

Note: I migrated to dotfiles.sh by Eli Schwartz, which is a thin wrapper for git that implements the method described here.

Setup Repository

Setup a bare git repository in your home directory. Bare repositories have no working directory, so setup an alias to avoid typing the long command. Add the git directory ~/.dotfiles/ to the gitignore as a security measure. Setup remote and push. Hide untracked files when querying the status.

git init --bare "$HOME/.dotfiles"

echo 'alias dotfiles="/usr/bin/env git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME"' \
    >> "$HOME/.zshrc"
source "$HOME/.zshrc"

echo '.dotfiles' >> "$HOME/.gitignore"
dotfiles add "$HOME/.gitignore"
dotfiles commit -m 'Git: Add gitignore'

dotfiles remote add origin https://github.com/alfunx/.dotfiles
dotfiles push --set-upstream origin master
dotfiles config --local status.showUntrackedFiles no

Track Files

Use the default git subcommands to track, update and remove files. You can obviously also use branches and all other features of git.

dotfiles status
dotfiles add .zshrc
dotfiles commit -m 'Zsh: Add zshrc'
dotfiles add .vimrc
dotfiles commit -m 'Vim: Add vimrc'
dotfiles push

To remove a file from the repository while keeping it locally you can use:

dotfiles rm --cached ~/.some_file

Restore Configurations

First clone dependent repositories, in this case for example oh-my-zsh. Clone your dotfiles repository as bare repository. Setup temporary alias and then checkout. If there exist files that collide with your repository (like a default .bashrc), the files will be moved to ~/.dotfiles.bak/. Then update all submodules and again hide untracked files when querying the status.

git clone https://github.com/robbyrussell/oh-my-zsh \
    "$HOME/.oh-my-zsh"

git clone --bare --recursive https://github.com/alfunx/.dotfiles \
    "$HOME/.dotfiles"

function dotfiles() {
    /usr/bin/env git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@"
}

dotfiles checkout
if [ "$?" -ne 0 ]; then
    mkdir -p "$HOME/.dotfiles.bak"
    dotfiles checkout 2>&1 \
        | grep -P '^\s+[\w.]' \
        | awk {'print $1'} \
        | xargs -I{} sh -c 'cp -r --parents "{}" "$HOME/.dotfiles.bak/" && rm -rf "{}"'
    dotfiles checkout
fi

dotfiles submodule update --recursive --remote
dotfiles config --local status.showUntrackedFiles no

Note that the automatic moving of already existing (thus conflicting) files fails if there are too many of them (git cuts the message at some point).

The short variant, using a script with the commands above:

. <(curl -Ls https://dotfiles.mariya.ch)

(Note: This is for my personal use. Instead of directly sourcing the install script, you should save it somewhere on your system and review it.)

Additional Commands

Instead of the alias provided above, you can use following function. listall will show all tracked files, listtree will show those files in a tree format (requires the package treeify). You may need to use a pager for these commands.

dotfiles() {
    case "$1" in
        listall)
            shift
            dotfiles ls-tree --full-tree -r --name-only HEAD "$@"
            ;;
        listtree)
            shift
            if hash treeify 2>/dev/null; then
                dotfiles ls-tree --full-tree -r --name-only HEAD "$@" | treeify
            else
                dotfiles listall
            fi
            ;;
        *)
            /usr/bin/env git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME" "$@"
            ;;
    esac
}

compdef can provide zsh autocompletion of the git command for your equivalent dotfiles command.

compdef dotfiles='git'