-This package provides automatic synchronization of assorted dotfiles,
-simplifying the maintenance of a uniform configuration across several
-hosts.
+This repository contains public dotfiles for my basic workstation.
+Use my `dotfiles-framework`_ to install.
-The `original implentation`_ was by Steve Kemp.
-
-_original implementation: http://dotfiles.repository.steve.org.uk
-
-Installation
-------------
-
-To install dotfiles, you'll need to check out a copy of the source,
-either by using `git`:
-
- $ git clone http://physics.drexel.edu/~wking/code/git/dotfiles.git
-
-or by downloading and unpacking a tarball:
-
- $ wget http://physics.drexel.edu/~wking/code/tar/dotfiles.tgz
- $ tar -xvf dotfiles.tgz
-
-It's up to you where you keep the unpacked source. Popular choices
-are `~/src/dotfiles` and `~/.dotfiles`. Once you've unpacked the
-source, set the `DOTFILES_DIR` environment variable to the source
-directory:
-
- $ export DOTFILES_DIR=~/src/dotfiles/
-
-If you're using Git, you may have a choice of transport protocols for
-accessing the central repository. Some protocols (e.g. SSH) often
-require you to authenticate before you are allowed access. Because
-dotfiles will try and update your local repository as you log in, make
-sure you set up your authentication mechanism (e.g. SSH agent) before
-running `dotfiles.sh`. If you don't want to bother authenticating,
-use a protocol that does not require authentication (e.g. HTTP) in
-your default pull URL.
-
-If you aren't using Git, you'll need to set the `DOTFILES_TGZ`
-environment variable so dotfiles knows where to look for updated
-versions of your central source:
-
- $ export DOTFILES_TGZ="http://physics.drexel.edu/~wking/code/tar/dotfiles.tgz"
-
-Once you've setup the environment variables, you can run
-`bin/dotfiles.sh` to install dotfiles-controlled versions of any
-dotfiles that you don't already have.
-
-Maintenance
------------
-
-In order to stay abreast of changes to the central repository, you
-should run `dotfiles.sh` periodically. An easy way to accomplish this
-is to source `${DOTFILES_DIR}/src/.bashrc.d/dotfiles` in your
-`~/.bashrc` (as I do at the end of my central `.bashrc`). This will
-call `dotfiles.sh` whenever you open a Bash shell, ensuring you're
-always up-to-date at the start of your session.
-
-After syncing with the central server, any local patches
-(`${DOTFILES_DIR}/local-patch/*.patch`) are applied and filenames
-`${DOTFILES_DIR}/local-patch/*.remove` are removed to adapt to the local
-system. As with installation, symlinks are automatically created for
-any dotfile (`${DOTFILES_DIR}/XXX`) that does not already have a
-locally installed version (`~/XXX`).
-
-If you followed the installation instructions above, you may have
-received warnings about files that you already have that dotfiles
-wants to control. You have two options for dealing with these
-collisions:
-
-1. Control the file yourself. In this case, you should add the
- filename to a `local-patch/*.remove` file, so that dotfiles knows
- you've assumed control.
-2. Delegate control to dotfiles. In this case, you should remove your
- local version of the file. Dotfiles will symlink in its version
- the next time you run `dotfiles.sh`. If you have many such files,
- `link.sh --force` will overwrite all of them at once.
-
-Local differences
------------------
-
-As we hinted at above, you can tailor how closely your local dotfiles
-installation tracks the central repository. Using
-`local-patch/*.remove` allows you to select purely-local control for
-files. When you only need a small tweak to central version, use
-`local-patch/*.patch`, giving some degree of shared control. You run
-
- $ cd "${DOTFILES_DIR}"
- $ ./bin/diff.sh --local-patch
-
-To create `.patch` and `.remove` files that recreate your currently
-installed state from the current source state. Edit (and optionally
-rename) these files to get the exact set of local adjustments you
-need.
+.. _dotfiles-framework:
+ http://physics.drexel.edu/~wking/unfolding-distasters/posts/Dotfiles/
+++ /dev/null
-#!/bin/bash
-#
-# Print diffs for each _FILE, ~/.FILE pair
-#
-# There are two modes: removed and standard. In standard mode, we show
-# the transition .file -> ~/.file, which shows the changes changes we
-# need to apply to dotfiles to create your current local installation.
-# In remove mode, we list the .files that do not have local ~/.file
-# analogs (i.e. dotfiles that need to be removed to create your
-# current local installation). The --removed option selects removed
-# mode.
-
-if [ -z "${DOTFILES_DIR}" ]; then
- echo "DOTFILES_DIR is not set. Bailing out."
- exit 1
-fi
-
-MODE='standard'
-
-# parse options
-while [ -n "${1}" ]; do
- case "${1}" in
- '--removed')
- MODE='removed'
- ;;
- '--local-patch')
- MODE='local-patch'
- ;;
- esac
- shift
-done
-
-if [ "${MODE}" = 'local-patch' ]; then
- cd "${DOTFILES_DIR}"
- mkdir -p local-patch || exit 1
- echo 'save local patches to local-patch/000-local.patch'
- ./bin/diff.sh > local-patch/000-local.patch || exit 1
- echo 'save local removes to local-patch/000-local.remove'
- ./bin/diff.sh --removed > local-patch/000-local.remove || exit 1
- exit
-fi
-
-cd "${DOTFILES_DIR}/src" || exit 1
-
-# Show the changes we'd apply on installation
-#
-# Parameters:
-# file - The file we're processing '.foo'
-function handle_file()
-{
- FILE="${1}"
- if [ "${MODE}" = 'removed' ]; then
- if [ ! -e ~/"${FILE}" ]; then
- echo "${FILE}"
- fi
- else
- if [ -f ~/"${FILE}" ]; then
- diff -u "${FILE}" ~/"${FILE}"
- fi
- fi
-}
-
-# For each file in this directory.
-FOUND=0
-while read FILE; do
- if [ "${FILE}" = '.' ]; then
- continue
- fi
- FILE="${FILE:2}" # strip the leading './'
- handle_file "${FILE}"
- let "FOUND = FOUND + 1"
-done < <(find .)
-
-# If we found no .XXX files, print a warning
-if [ "${FOUND}" -lt 1 ]; then
- echo 'WARNING: no source dotfiles were found' >&2
-fi
+++ /dev/null
-#!/bin/bash
-#
-# You're about to give your sysadmin account to some newbie, and
-# they'd just be confused by all this efficiency. This script freezes
-# your dotfiles in their current state and makes everthing look
-# normal. Note that this will delete your dotfiles directory, and
-# strip the dotfiles portion from your ~/.bashrc file.
-
-if [ -z "${DOTFILES_DIR}" ]; then
- echo 'DOTFILES_DIR is not set. Bailing out.'
- exit 1
-fi
-
-# See if we've constructed any patched source files that might be
-# possible link targets
-if [ ! -d "${DOTFILES_DIR}/patched-src" ]; then
- echo 'no installed dotfiles to disconnect'
- exit
-fi
-
-DOTFILES_SRC="${DOTFILES_DIR}/patched-src"
-cd "${DOTFILES_SRC}" || exit 1
-
-# See if the bashrc file is involved with dotfiles at all
-if [ -e '.bashrc' ]; then
- BASHRC='yes'
-else
- BASHRC='no'
-fi
-
-while read FILE; do
- if [ "${FILE}" = '.' ]; then
- continue
- fi
- FILE="${FILE:2}" # strip the leading './'
- if [ "${DOTFILES_SRC}/${FILE}" -ef ~/"${FILE}" ] && \
- [ -h ~/"${FILE}" ]; then
- # break simlink
- echo "de-symlink ~/${FILE}"
- rm -f ~/"${FILE}"
- mv "${FILE}" ~/"${FILE}"
- fi
-done < <(find .)
-
-if [ "${BASHRC}" == 'yes' ]; then
- echo 'strip dotfiles section from ~/.bashrc'
- sed '/DOTFILES_DIR/d' ~/.bashrc > bashrc_stripped
-
- # see if the stripped file is any different
- DIFF=$(diff ~/.bashrc bashrc_stripped)
- DIFF_RC="$?"
- if [ ${DIFF_RC} -eq 0 ]; then
- echo "no dotfiles section found in ~/.bashrc"
- rm -f bashrc_stripped
- elif [ ${DIFF_RC} -eq 1 ]; then
- echo "replace ~/.bashrc with stripped version"
- rm -f ~/.bashrc
- mv bashrc_stripped ~/.bashrc
- else
- exit 1 # diff failed, bail
- fi
-fi
-
-#if [ -d "${DOTFILES_DIR}" ]; then
-# cd
-# echo "remove the dotfiles dir ${DOTFILES_DIR}"
-# rm -rf "${DOTFILES_DIR}"
-#fi
+++ /dev/null
-#!/bin/bash
-
-if [ -z "${DOTFILES_DIR}" ]; then
- echo 'DOTFILES_DIR is not set. Bailing out.'
- exit 1
-fi
-
-cd "${DOTFILES_DIR}" || exit 1
-
-# Update once a week from our remote repository. Mark updates by
-# touching this file.
-UPDATE_FILE="updated.$(date +%U)"
-
-if [ ! -e "${UPDATE_FILE}" ]; then
- echo "update dotfiles"
- rm -f updated.* 2>/dev/null
- touch "${UPDATE_FILE}"
- ./bin/fetch.sh || exit 1
- ./bin/patch.sh || exit 1
- ./bin/link.sh || exit 1
- echo "dotfiles updated"
-fi
+++ /dev/null
-#!/bin/bash
-#
-# Get the current dotfiles from the server using a variety of methods.
-#
-# If there is a .git directory in $DOTFILES_DIR, use `git pull`,
-# otherwise use wget to grab a tarball.
-
-if [ -z "${DOTFILES_DIR}" ]; then
- echo 'DOTFILES_DIR is not set. Bailing out.'
- exit 1
-fi
-
-cd "${DOTFILES_DIR}" || exit 1
-
-# Check for Git (versioning system) so we know how to get our .dotfiles
-if [ -d .git ];then
- git pull || exit 1
-else
- # fallback on wgetting the tarball
- if [ -z "${DOTFILES_TGZ}" ]; then
- echo 'DOTFILES_TGZ is not set. Bailing out.'
- exit 1
- fi
- wget --output-document dotfiles.tgz "${DOTFILES_TGZ}" || exit 1
- tar -xzvf dotfiles.tgz || exit 1
- rm -rf dotfiles.tgz || exit 1
-fi
+++ /dev/null
-#!/bin/bash
-#
-# Link each FILE in patched-src to ~/FILE
-#
-# By default, link.sh only replaces missing files and simlinks. You
-# can optionally overwrite any local files by passing the --force
-# option.
-
-if [ -z "${DOTFILES_DIR}" ]; then
- echo 'DOTFILES_DIR is not set. Bailing out.'
- exit 1
-fi
-
-DOTFILES_SRC="${DOTFILES_DIR}/patched-src"
-FORCE='no' # If 'file', overwrite existing files.
- # If 'yes', overwrite existing files and dirs.
-DRY_RUN='no' # If 'yes', disable any actions that change the filesystem
-
-# parse options
-while [ -n "${1}" ]; do
- case "${1}" in
- '--force')
- FORCE='yes'
- ;;
- '--force-file')
- FORCE='file'
- ;;
- '--dry-run')
- DRY_RUN='yes'
- ;;
- esac
- shift
-done
-
-# Create the symbolic link, overriding the target if it exists.
-#
-# link_file( $file )
-#
-# Parameters:
-# file - The file we're processing '.foo'
-function link_file()
-{
- FILE="${1}"
- if [ -e ~/"${FILE}" ] || [ -h ~/"${FILE}" ]; then
- if [ "${DRY_RUN}" = 'yes' ]; then
- echo "move ~/${FILE} to ~/${FILE}.bak"
- else
- echo -n 'move '
- mv -v ~/"${FILE}" ~/"${FILE}.bak" || exit 1
- fi
- fi
- if [ "${DRY_RUN}" = 'yes' ]; then
- echo "link ~/${FILE} to ${DOTFILES_DIR}/${FILE}"
- else
- echo -n 'link '
- ln -sv "${DOTFILES_DIR}/patched-src/${FILE}" ~/"${FILE}" || exit 1
- fi
-}
-
-cd "${DOTFILES_DIR}/patched-src" || exit 1
-
-while read FILE; do
- if [ "${FILE}" = '.' ]; then
- continue
- fi
- FILE="${FILE:2}" # strip the leading './'
- if [ "${DOTFILES_SRC}/${FILE}" -ef ~/"${FILE}" ]; then
- continue # already simlinked
- fi
- if [ -d "${DOTFILES_SRC}/${FILE}" ] && [ -d ~/"${FILE}" ] && \
- [ "${FORCE}" != 'yes' ]; then
- echo "use --force to override the existing directory: ~/${FILE}"
- continue # allow unlinked directories
- fi
- if [ -e ~/"${FILE}" ] && [ "${FORCE}" = 'no' ]; then
- echo "use --force to override the existing target: ~/${FILE}"
- continue # target already exists
- fi
- link_file "${FILE}"
-done < <(find .)
+++ /dev/null
-#!/bin/bash
-#
-# Patch a fresh checkout with local adjustments.
-
-if [ -z "${DOTFILES_DIR}" ]; then
- echo 'DOTFILES_DIR is not set. Bailing out.'
- exit 1
-fi
-
-cd "${DOTFILES_DIR}" || exit 1
-
-# clone the checkout into DOTFILES_DIR/patched-src
-echo "clone clean checkout into patched-src"
-rsync -avz --delete src/ patched-src/ || exit 1
-
-# apply all the patches in local-patch/
-for PATCH in local-patch/*.patch; do
- if [ -f "${PATCH}" ]; then
- echo "apply ${PATCH}"
- pushd patched-src/ > /dev/null || exit 1
- patch -p0 < "../${PATCH}" || exit 1
- popd > /dev/null || exit 1
- fi
-done
-
-# remove any files marked for removal in local-patch
-for REMOVE in local-patch/*.remove; do
- if [ -f "${REMOVE}" ]; then
- while read LINE; do
- if [ -z "${LINE}" ] || [ "${LINE:0:1}" = '#' ]; then
- continue # ignore blank lines and comments
- fi
- if [ -e "patched-src/${LINE}" ]; then
- echo "remove ${LINE}"
- rm -rf "patched-src/${LINE}"
- fi
- done < "${REMOVE}"
- fi
-done