--- /dev/null
+patched-src
+local-patch
+updated.*
+++ /dev/null
-# ~/.dotfiles/Makefile
-#
-# all:
-# Link all the files we have in this directory into the parent.
-#
-# clean:
-# Clean editted files.
-#
-# Original by Steve Kemp (http://www.steve.org.uk)
-
-all: fixup
-
-clean:
- find . -name '*~' -exec rm -f \{\} \;
- find . -name '.#*' -exec rm -f \{\} \;
-
-diff:
- git diff
-
-# Link each _FILE in the current directory to ~/.FILE
-fixup: update
- ./fixup.sh
-
-# By default, fixup only replaces missing files and simlinks. You can
-# optionally overwrite any local files and directories by passing the
-# --force option.
-override:
- ./fixup.sh --force
-
-# Get the current dotfiles from the server using a variety of methods.
-update:
- ./update.sh
-
-# Print a diff between the local installation and .dotfiles
-# i.e. What changes will `make override' effect
-localdiff:
- ./diff.sh --local
-
-# Save a diff between .dotfiles and the local installation
-# i.e. What specialization do I want compared to the central .dotfiles
-localpatch:
- ./diff.sh > local.patch
-
-# No Remove this computer from the auto-updates list
-disconnect:
- ./disconnect.sh
simplifying the maintenance of a uniform configuration across several
hosts.
-The basic implentation was by Steve Kemp at
- http://dotfiles.repository.steve.org.uk
-
-To install it, simple replace your ~/.bashrc file with mine (or at
-least replace the portions dealing with ~.dotfiles). Whenever you
-open a bash shell, that code will check for the existence of a
-~/.dotfiles directory, and if necessary, download it from my public
-repository (ideally using git, but it falls back on wgetting a
-tarball). It then creates simlinks to any dotfiles that you had been
-missing automatically.
-
-After installation, the code in your .bashrc file will check for
-weekly updates at the central server. Any updates to the files that
-it controls (i.e. dotfiles symlinked into ~/.dotfiles/_XXX) will be
-applied automatically.
-
-In order to increase your local installation's similarity with the
-central server, take a look at the differences between your installed
-dotfiles and those in ~/.dotfile with
- cd ~/.dotfiles
- make localdiff | less
-If you see a few places where you like your local version better, make
-a patch, and save the hunks in (see *making local.patch* below)
- ~/.dotfiles/local.patch
-You can do a dry run of any update with
- cd ~/.dotfiles && ./fixup.sh --dry-run
-or overide with
- cd ~/.dotfiles && ./fixup.sh --dry-run --force
-Then put .dotfiles in control with
- make override
-which will replace all your local dotfiles with their .dotfiles version
-and then patch them as you specified in local.patch.
-
-
-Making local.patch
-
-Set up your installed dotfiles as you want them to be. (TODO: helper
-script for partial, interactive merges of the central version.) Then
-just
- make localpatch
+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.
+++ /dev/null
-# ~/.bash_logout: executed by bash(1) when login shell exits.
-
-# when leaving the console clear the screen to increase privacy
-
-if [ "$SHLVL" = 1 ]; then
- [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
-fi
+++ /dev/null
-# ~/.bashrc: executed by bash(1) for non-login shells.
-# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
-# for examples
-
-if [ -f /etc/bashrc ]; then
- . /etc/bashrc
-fi
-
-# personalize path
-export PATH=$HOME/bin:$HOME/script:$HOME/script/python:$HOME/script/lab:$HOME/lib/ruby/gems/1.8/bin:$HOME/.cabal/bin:$HOME/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
-export LD_LIBRARY_PATH=~/lib
-
-# personalize latex path
-export TEXINPUTS=":.:$HOME/projects/latex/common/"
-
-# personalize python path
-PYTHON_VERSION=$(python -c 'import sys; print ".".join([str(i) for i in sys.version_info[:2]])')
-export PYTHONPATH=".:$HOME/lib/python:$HOME/lib/python$PYTHON_VERSION/site-packages:$HOME/.python"
-
-# append personal manpages to manpath
-export MANPATH=":$HOME/share/man"
-
-# personalize Java path (found by tracing from `which javac`)
-export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
-
-# personalize ruby and rubygems paths
-# from http://docs.rubygems.org/read/chapter/15
-PREFIX=$HOME
-export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
-export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8
-
-
-# If not running interactively, don't do anything else
-[ -z "$PS1" ] && return
-
-# don't put duplicate line in the history and ignore lines starting
-# with a space. See bash(1).
-export HISTCONTROL=ignoreboth
-
-# check the window size after each command and, if necessary,
-# update the values of LINES and COLUMNS.
-shopt -s checkwinsize
-
-# make less more friendly for non-text input files, see lesspipe(1)
-[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
-
-# set variable identifying the chroot you work in (used in the prompt below)
-if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
-fi
-
-# adjust for Ubuntu not recognizing screen.* terms
-if [ "${TERM:0:7}" == "screen." ]; then
- export TERM="${TERM:7}"
-fi
-
-# set a fancy prompt (non-color, unless we know we "want" color)
-case "$TERM" in
- xterm-color) color_prompt=yes;;
-esac
-
-# uncomment for a colored prompt, if the terminal has the capability; turned
-# off by default to not distract the user: the focus in a terminal window
-# should be on the output of commands, not on the prompt
-force_color_prompt=yes
-
-if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
-fi
-
-if [ "$color_prompt" = yes ]; then
- # \[\033[XXm\] sets the color. XX = 00:default, 31:red, 33:yellow
- PS1='${debian_chroot:+($debian_chroot)}\[\033[31m\]\u@\h\[\033[00m\]:\[\033[33m\]\W\[\033[00m\]\$ '
-else
- PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '
-fi
-unset color_prompt force_color_prompt colorA colorB
-
-# If this is an xterm set the title to user@host:dir
-case "$TERM" in
-xterm*|rxvt*)
- PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
- ;;
-*)
- ;;
-esac
-
-# Alias definitions.
-# You may want to put all your additions into a separate file like
-# ~/.bash_aliases, instead of adding them here directly.
-# See /usr/share/doc/bash-doc/examples in the bash-doc package.
-
-#if [ -f ~/.bash_aliases ]; then
-# . ~/.bash_aliases
-#fi
-
-# Make file system utilities friendlier
-alias rm='rm -iv'
-alias rmdir='rmdir -v'
-alias cp='cp -iv'
-alias mv='mv -iv'
-alias less='less -R'
-
-# Configure useful programs
-alias lp='/usr/bin/lp -o sides=two-sided-long-edge -o media=letter -o cpi=16 -o lpi=10'
-alias lpb='/usr/bin/lp -o sides=two-sided-long-edge -o media=letter -o cpi=12 -o lpi=6'
-alias lpi='/usr/bin/lp -o fitplot'
-alias emacs='emacs -nw'
-alias xterm='xterm -fg white -bg black'
-alias w3mg='w3m http://www.google.com'
-alias w3mh='w3m http://www.physics.drexel.edu/~wking/'
-alias calendar='calendar -A28'
-alias acroread='acroread -geometry 1270x950'
-alias graph='graph -TX -C'
-alias snownews='snownews -u'
-alias oggr='ogg123 -qb 500' # play ogg radio streams (quiet, big input buffer)
-
-# Alias useful one-liners & common commands
-alias findex='find . -perm -u+x ! -type d'
-alias sortdat='find . -printf "%TY-%Tm-%Td+%TH:%TM:%TS %h/%f\n" | sort -n'
-alias sortdirdat='find . -type d -printf "%TY-%Tm-%Td+%TH:%TM:%TS %h/%f\n" | sort -n'
-alias sshy='ssh wking@129.25.24.53'
-alias ssha='ssh sysadmin@129.25.7.55'
-alias sshxa='ssh -X sysadmin@129.25.7.55'
-
-# enable color support of ls and also add handy aliases
-if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
- eval "`dircolors -b`"
- alias ls='ls --color=auto'
- #alias dir='ls --color=auto --format=vertical'
- #alias vdir='ls --color=auto --format=long'
-
- alias grep='grep --color=auto'
- #alias fgrep='fgrep --color=auto'
- #alias egrep='egrep --color=auto'
-fi
-
-# some more ls aliases
-alias ll='ls -l'
-alias la='ls -A'
-alias l='ls -CF'
-
-# enable programmable completion features (you don't need to enable
-# this if it's already enabled in /etc/bash.bashrc and /etc/profile
-# sources /etc/bash.bashrc).
-if [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
-fi
-
-# define default programs
-export EDITOR="/usr/bin/emacs -nw"
-export PAGER="less"
-
-# colorize file listings (di was 34 (blue), swapped with 33 (yellow))
-export LS_COLORS='no=00:fi=00:di=00;33:ln=00;36:pi=40;34:so=00;35:bd=40;34;01:cd=40;34;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
-
-# turn off terminal beep in X
-if [ $TERM == "xterm" ] && [ -n "$DISPLAY" ]
- then
- xset b off
-fi
-
-# turn of terminal beeps in the console, unless connecting via SSH
-if [ -z "$SSH_CLIENT" ]; then
- if [ ! -z "$TERM" ]; then
- setterm -blength 0
- fi
-fi
-
-SSH_INFO_FILE="/tmp/$(whoami)/.ssh/.ssh-agent-info-$(hostname)"
-if [ -f "$SSH_INFO_FILE" ]; then
- . "$SSH_INFO_FILE"
-fi
-
-### ---- begin .dotfiles section ---- (keep this magic comment)
-
-# Check for Git (versioning system) so we know how to get our .dotfiles
-GIT_PATH=`which git`
-if [ -n "$GIT_PATH" ];then
- GIT_INSTALLED="true"
-else
- GIT_INSTALLED="false"
-fi
-
-# If we don't have checked out copies of our dotfiles, get them
-if [ ! -d ~/.dotfiles/ ]; then
- http="http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git"
- ssh="http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git"
- tgz="http://einstein.physics.drexel.edu/~wking/code/tar/dotfiles.tgz"
- if [ $GIT_INSTALLED == "true" ]; then
- git clone $http ~/.dotfiles
- # setup to use ssh by default.
- sed -i "s/$http/$ssh/" ~/.dotfiles/.git/config
- else
- # fallback on wgetting the tarball
- pushd ~
- wget --output-document dotfiles.tgz $tgz
- tar -xzvf dotfiles.tgz
- rm -rf dotfiles.tgz
- popd
- fi
-fi
-
-# If we have checked out copies of our dotfiles (i.e. clone successful)
-if [ -d ~/.dotfiles/ ]; then
- # Update once a week from our remote repository.
- if [ ! -e ~/.dotfiles/updated.`date +%U` ]; then
- rm -f ~/.dotfiles/updated.* 2>/dev/null
- touch ~/.dotfiles/updated.`date +%U`
- pushd ~/.dotfiles
- make fixup
- popd
- fi
-fi
-
-### ---- end .dotfiles section ---- (keep this magic comment)
--- /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 < "../${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
+++ /dev/null
-#!/bin/bash
-#
-# Print diffs for each _FILE, ~/.FILE pair
-#
-# There are two modes, local and standard. In standard mode, we show the
-# transition ~/.file -> _file, which shows the changes effected by
-# `make override`. In local mode we show the transition _file -> ~/.file,
-# which shows the changes we need to apply to the .dotfiles to create
-# your current local installation. The --local option selects local mode.
-
-LOCAL="no" # Select diff ordering
-
-# parse options
-while [ -n "$1" ]; do
- case "$1" in
- "--local")
- LOCAL="yes"
- ;;
- esac
- shift
-done
-
-# Show the changes we'd apply on installation
-#
-# handleFile( $file, $dotfile )
-#
-# Parameters:
-# file - The file we're processing '_foo'
-# dotfile - The file it should be linked to in ~/, e.g. '.foo'
-function handleFile( )
-{
- if [ $LOCAL == "yes" ]; then
- diff -ru $2 $1
- else
- diff -ru $1 $2
- fi
-}
-
-# See if we can find any _files.
-found=0
-for i in _*; do
- if [ -e $i ]; then
- found=`expr $found + 1`
- fi
-done
-
-# If we found none then exit
-if [ "$found" -lt 1 ]; then
- echo "WARNING: No files matching _* were found"
- exit
-fi
-
-# For each file in this directory.
-for i in _*; do
- # Create .dotfile version.
- dotfile=.${i/_/}
-
- if [ ! -e ~/$dotfile ]; then
- echo "~/$dotfile doesn't exist"
- else
- # run the diff
- handleFile $i ~/$dotfile
- fi
-done
+++ /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.
-
-# See if the bashrc file is involved with .dotfiles at all
-if [ -e _bashrc ]; then
- BASHRC="yes"
-else
- BASHRC="no"
-fi
-
-# For each file in this directory.
-for file in _*; do
- # Create .dotfile version.
- dotfile=.${file/_/}
-
- # Replace symlinks with their target
- if [ -h ~/$dotfile ]; then
- echo "De-symlink ~/$dotfile"
- rm -f ~/$dotfile
- mv $file ~/$dotfile
- fi
-done
-
-if [ $BASHRC == "yes" ]; then
- # We may have a dotfiles section in ~/.bashrc. Strip it out.
- BC="### ---- begin .dotfiles section ---- (keep this magic comment)"
- EC="### ---- end .dotfiles section ---- (keep this magic comment)"
- AWKSCRIPT="BEGIN{copy=1}{"
- AWKSCRIPT="$AWKSCRIPT if(\$0 == \"$BC\"){copy=0};"
- AWKSCRIPT="$AWKSCRIPT if(\$0 == \"$EC\"){copy=1};"
- AWKSCRIPT="$AWKSCRIPT if(copy==1 && \$0 != \"$EC\"){print \$0}"
- AWKSCRIPT="$AWKSCRIPT}"
-
- echo "Strip dotfiles section from ~/.bashrc"
- awk "$AWKSCRIPT" ~/.bashrc > bashrc_stripped
-
- # see if the stripped file is any different
- DIFF=`diff ~/.bashrc bashrc_stripped`
- if [ $? -ne 1 ]; then exit 1; fi # diff failed, bail
- if [ -n "$DIFF" ]; then
- echo "Replace ~/.bashrc with stripped version"
- rm -f ~/.bashrc
- cp bashrc_stripped ~/.bashrc
- else
- echo "No dotfiles section in ~/.bashrc"
- fi
-fi
-
-DOTFILES_DIR=`pwd`
-cd
-echo "Remove the dotfiles dir $DOTFILES_DIR"
-rm -rf $DOTFILES_DIR
+++ /dev/null
-#!/bin/bash
-#
-# Link each _FILE in the current directory to ~/.FILE
-#
-# Originally by Steve Kemp (http://www.steve.org.uk/)
-#
-# By default, fixup only replaces missing files and simlinks. You can
-# optionally overwrite any local files and directories by passing the
-# --force option.
-
-FORCE="no" # If "yes", overwrite existing .files
-DRY_RUN="no" # If "yes", disable any actions that change the filesystem
-
-# parse options
-while [ -n "$1" ]; do
- case "$1" in
- "--force")
- FORCE="yes"
- ;;
- "--dry-run")
- DRY_RUN="yes"
- ;;
- esac
- shift
-done
-
-# Create the symbolic link.
-#
-# linkFiles( $file, $dotfile )
-#
-# Parameters:
-# file - The file we're processing '_foo'
-# dotfile - The file it should be linked to in ~/, e.g. '.foo'
-function linkFiles ( )
-{
- file=$1
- dotfile=$2
- ln -s `pwd`/$file ~/$dotfile
-}
-
-# Check if a file is patch controlled
-#
-# isPatchFile( $file, $patchfiles)
-#
-# Parameters:
-# file - The file we're processing '_foo'
-# patchfiles - A string list of patchfiles
-function isPatchFile( )
-{
- file=$1
- shift
- patchfiles=$*
-
- for patchfile in $patchfiles; do
- if [ $file == $patchfile ]; then
- return 0
- fi
- done
- return 1
-}
-
-# Check if a file is controlled by the dotfiles framework
-#
-# isControlledFile( $file, $patchfiles )
-#
-# Parameters:
-# file - The file we're processing '_foo'
-# patchfiles - A string list of patchfiles
-function isControlledFile( )
-{
- file=$1
- shift
- patchfiles=$*
- dotfile=.${file/_/}
-
- if [ ! -e ~/$dotfile ]; then
- #echo "~/$dotfile is controlled (does not exist)"
- return 0
- elif [ -h ~/$dotfile ]; then
- #echo "~/$dotfile is controlled (a symlink)"
- return 0
- elif isPatchFile $file $patchfiles; then
- #echo "~/$dotfile is controlled (a patchfile)"
- return 0
- fi
- #echo "~/$dotfile is not controlled"
- return 1
-}
-
-# Check if the installed file matches the dotfiles version
-#
-# fileChanged( $file, $dotfile )
-#
-# Parameters:
-# file - The file we're processing '_foo'
-# dotfile - The file it should be linked to in ~/, e.g. '.foo'
-function fileChanged()
-{
- file=$1
- dotfile=$2
- DIFF=`diff -r ~/$dotfile $file`
- [ -z "$DIFF" ]
- return $?
-}
-
-# Prettyprint a list of files
-#
-# listFiles( $title, $list )
-#
-# Parameters:
-# title - The name of the list
-# list - The files in the list
-function listFiles()
-{
- title=$1
- shift
- files=$*
- if [ $# -gt 0 ]; then
- echo "$title: ($#)"
- for file in $files; do
- echo " $file"
- done
- fi
-}
-
-
-# See if we can find any _files.
-found=0
-for file in _*; do
- if [ -e $file ]; then
- found=`expr $found + 1`
- fi
-done
-
-# If we found none then exit
-if [ "$found" -lt 1 ]; then
- echo "WARNING: No files matching _* were found"
- exit
-fi
-
-# If a local.patch file exists, apply it's changes to our dotfiles
-# files. We catch the output of this to get a list of the files under
-# local.patch control
-if [ -f "local.patch" ]; then
- patchoption=""
- if [ $DRY_RUN == "yes" ]; then
- patchoption="--dry-run"
- fi
- echo "\$ patch $patchoption -i local.patch"
- patchout=`patch $patchoption -i local.patch || exit 1`
- echo "$patchout"
- echo ""
- # e.g. patchout:
- # patching file _emacs
- # patching file _gnuplot
- PATCHFILES=`echo "$patchout" | sed -n 's/patching file //p'`
- #listFiles "Patched files" $PATCHFILES
-fi
-
-IGNORED=""
-NOT_CHANGED=""
-UPDATED=""
-ADDED=""
-
-# For each dotfile in this directory.
-for file in _*; do
- # Create .dotfile version.
- dotfile=.${file/_/}
-
- # Decide what to do with files we don't normally control
- OVERRIDDEN="no"
- if ! isControlledFile $file $PATCHFILES; then
- if [ $FORCE == "yes" ]; then
- OVERRIDDEN="yes"
- UPDATED="$UPDATED ~/$dotfile"
- if [ $DRY_RUN == "no" ]; then
- # Back up the ~/$dotfile
- mv ~/$dotfile ~/$dotfile.bak
- fi
- else
- IGNORED="$IGNORED ~/$dotfile"
- continue
- fi
- fi
-
- # Targets getting to this point should be controlled
- if [ -e ~/$dotfile ]; then
- # The target exists, see if it has changed
- if fileChanged $file $dotfile; then
- NOT_CHANGED="$NOT_CHANGED ~/$dotfile"
- continue
- else
- if [ $OVERRIDDEN == "no" ]; then
- UPDATED="$UPDATED ~/$dotfile"
- fi
- if [ $DRY_RUN == "no" ]; then
- # Back up the ~/$dotfile
- mv ~/$dotfile ~/$dotfile.bak
- fi
- fi
- else
- if [ $OVERRIDDEN == "no" ]; then
- ADDED="$ADDED ~/$dotfile"
- fi
- fi
- if isPatchFile $file $PATCHFILES; then
- if [ $DRY_RUN == "no" ]; then
- # Install the patched ~/$dotfile
- cp $file ~/$dotfile
- fi
- else
- if [ $DRY_RUN == "no" ]; then
- # Install a symlink ~/$dotfile
- linkFiles $file $dotfile
- fi
- fi
-done
-
-listFiles "Added" $ADDED
-listFiles "Updated" $UPDATED
-listFiles "NotChanged" $NOT_CHANGED
-listFiles "Ignored" $IGNORED
-
-# Revert the action of the patch on our dotfiles files now that we've
-# installed the patched versions.
-if [ -f "local.patch" ] && [ $DRY_RUN == "no" ]; then
- echo ""
- echo '$ patch -i local.patch -R'
- patch -i local.patch -R
-fi
--- /dev/null
+# Make file system utilities friendlier
+alias rm='rm -iv'
+alias rmdir='rmdir -v'
+alias cp='cp -iv'
+alias mv='mv -iv'
+alias less='less -R'
+
+# Configure useful programs
+alias lp='/usr/bin/lp -o sides=two-sided-long-edge -o media=letter -o cpi=16 -o lpi=10'
+alias lpb='/usr/bin/lp -o sides=two-sided-long-edge -o media=letter -o cpi=12 -o lpi=6'
+alias lpi='/usr/bin/lp -o fitplot'
+alias emacs='emacs -nw'
+alias xterm='xterm -fg white -bg black'
+alias w3mg='w3m http://www.google.com'
+alias w3mh='w3m http://www.physics.drexel.edu/~wking/'
+alias calendar='calendar -A28'
+alias acroread='acroread -geometry 1270x950'
+alias graph='graph -TX -C'
+alias snownews='snownews -u'
+alias oggr='ogg123 -qb 500' # play ogg radio streams (quiet, big input buffer)
+
+# Alias useful one-liners & common commands
+alias findex='find . -perm -u+x ! -type d'
+alias sortdat='find . -printf "%TY-%Tm-%Td+%TH:%TM:%TS %h/%f\n" | sort -n'
+alias sortdirdat='find . -type d -printf "%TY-%Tm-%Td+%TH:%TM:%TS %h/%f\n" | sort -n'
+alias sshy='ssh wking@129.25.24.53'
+alias ssha='ssh sysadmin@129.25.7.55'
+alias sshxa='ssh -X sysadmin@129.25.7.55'
+
+# enable color support of ls and also add handy aliases
+if [ "$TERM" != "dumb" ] && [ -x /usr/bin/dircolors ]; then
+ eval "`dircolors -b`"
+ alias ls='ls --color=auto'
+ #alias dir='ls --color=auto --format=vertical'
+ #alias vdir='ls --color=auto --format=long'
+
+ alias grep='grep --color=auto'
+ #alias fgrep='fgrep --color=auto'
+ #alias egrep='egrep --color=auto'
+fi
+
+# some more ls aliases
+alias ll='ls -l'
+alias la='ls -A'
+alias l='ls -CF'
--- /dev/null
+# ~/.bash_logout: sourced by bash(1) when a login shell terminates.
+
+# Clear the screen for security's sake.
+clear
-# ~/.bash_profile: executed by bash(1) for login shells.
-# see /usr/share/doc/bash/examples/startup-files for examples.
-# the files are located in the bash-doc package.
+# This file is sourced by bash for login shells.
-# the default umask is set in /etc/login.defs
-#umask 022
-
-# include .bashrc if it exists
-if [ -f ~/.bashrc ]; then
- . ~/.bashrc
-fi
+# The following line runs your .bashrc and is recommended by the bash
+# info pages.
+[[ -f ~/.bashrc ]] && . ~/.bashrc
# set PATH so it includes user's private bin if it exists
if [ -d ~/bin ]; then
--- /dev/null
+# This file is sourced by all *interactive* bash shells on startup,
+# including some apparently interactive shells such as scp and rcp
+# that can't tolerate any output. So make sure this doesn't display
+# anything or bad things will happen!
+
+# Test for an interactive shell. There is no need to set anything
+# past this point for scp and rcp, and it's important to refrain from
+# outputting anything in those cases.
+if [[ $- != *i* ]] ; then
+ # Shell is non-interactive. Be done now!
+ return
+fi
+
+#source .bashrc.d/local_paths
+
+# If not running interactively, don't do anything else
+[ -z "$PS1" ] && return
+
+# don't put duplicate line in the history and ignore lines starting
+# with a space. See bash(1).
+export HISTCONTROL=ignoreboth
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+source .bashrc.d/environment
+#source .bashrc.d/screen
+#source .bashrc.d/completion
+#source .bashrc.d/nobeep
+#source .bashrc.d/lesspipe
+source .bashrc.d/ssh_agent
+source .bashrc.d/gpg_agent
+
+# load aliases
+if [ -f ~/.bash_aliases ]; then
+ . ~/.bash_aliases
+fi
+
+source "${DOTFILES_DIR}/src/.bashrc.d/dotfiles"
--- /dev/null
+# enable programmable completion features (you don't need to enable
+# this if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
+
+# bugs-everywhere completion
+if [ -f ~/.be-completion.sh ]; then
+ source ~/.be-completion.sh
+fi
--- /dev/null
+# Run the dotfiles.sh script if it exists
+
+DS="${DOTFILES_DIR}/bin/dotfiles.sh"
+if [ -f "${DS}" ] && [ -x "${DS}" ]; then
+ "${DS}";
+fi
--- /dev/null
+# path to local dotfiles checkout
+export DOTFILES_DIR=~/"src/dotfiles"
+
+# define default programs
+export EDITOR="/usr/bin/emacs -nw"
+export PAGER="less"
+
+# colorize file listings (di was 34 (blue), swapped with 33 (yellow))
+#export LS_COLORS='no=00:fi=00:di=00;33:ln=00;36:pi=40;34:so=00;35:bd=40;34;01:cd=40;34;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
+
+export MONKEYSPHERE_CHECK_KEYSERVER=false
--- /dev/null
+# GnuPG agent
+if [ -f "${HOME}/.gnupg/agent-info" ]; then
+ source "${HOME}/.gnupg/agent-info"
+fi
--- /dev/null
+# make less more friendly for non-text input files, see lesspipe(1)
+[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
--- /dev/null
+# set LD_LIBRARY_PATH so it includes user's private lib if it exists
+if [ -d ~/lib ]; then
+ LD_LIBRARY_PATH="~/lib"
+fi
+
+# append personal manpages to manpath
+export MANPATH=":$HOME/share/man"
+
+# personalize latex path
+export TEXINPUTS=":.:$HOME/projects/latex/common/"
+
+# personalize font path (Gnuplot uses gd to find fancy fonts)
+GDFONTPATH="";
+for x in $(find /usr/share/fonts/ -type d); do
+ GDFONTPATH="$GDFONTPATH:$x";
+done;
+GDFONTPATH="${GDFONTPATH:1}";
+export GDFONTPATH
+
+# personalize python path
+#
+# You should use distutil's `--user` option to install per-user
+# packages into ~/.local, which Python will pick up automatically.
+# This snippet is a relic of the days before `--user` when I used
+# `--prefix $HOME`.
+PYTHON_VERSION=$(python -c 'import sys; print ".".join([str(i) for i in sys.version_info[:2]])')
+export PYTHONPATH=".:$HOME/lib/python:$HOME/lib/python$PYTHON_VERSION/site-packages:$HOME/.python"
+
+# personalize Java path (found by tracing from `which javac`)
+export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/
+
+# personalize ruby and rubygems paths
+# from http://docs.rubygems.org/read/chapter/15
+PREFIX=$HOME
+export GEM_HOME=$PREFIX/lib/ruby/gems/1.8
+export RUBYLIB=$PREFIX/lib/ruby:$PREFIX/lib/site_ruby/1.8
--- /dev/null
+# turn off terminal beep in X
+if [ $TERM == "xterm" ] && [ -n "$DISPLAY" ]
+ then
+ xset b off
+fi
+
+# turn of terminal beeps in the console, unless connecting via SSH
+if [ -z "$SSH_CLIENT" ]; then
+ if [ ! -z "$TERM" ]; then
+ setterm -blength 0
+ fi
+fi
--- /dev/null
+# adjust for Ubuntu not recognizing screen.* terms
+if [ "${TERM:0:7}" == "screen." ]; then
+ export TERM="${TERM:7}"
+fi
--- /dev/null
+SSH_INFO_FILE="/tmp/$(whoami)/.ssh/.ssh-agent-info-$(hostname)"
+if [ -f "$SSH_INFO_FILE" ]; then
+ . "$SSH_INFO_FILE"
+fi
+++ /dev/null
-#!/bin/bash
-#
-# Get the current dotfiles from the server using a variety of methods.
-#
-# In order of decreasing preference:
-# if we have git installed
-# git over ssh, if there is an ssh agent running
-# git over http
-# otherwise
-# wget a tarball
-
-# The default ssh url is stored in .git/config, so we don't need it here
-http="http://einstein.physics.drexel.edu/~wking/code/git/dotfiles.git"
-tgz="http://einstein.physics.drexel.edu/~wking/code/tar/dotfiles.tgz"
-
-
-# Check for Git (versioning system) so we know how to get our .dotfiles
-if [ -d .git ];then
- GIT_INSTALLED="true"
-else
- GIT_INSTALLED="false"
-fi
-
-# Check for a SSH agent
-if [ -n "$SS_AUTH_SOCK" ] && [ -n "$SSH_AGENT_PID" ]; then
- SSH_AGENT="true"
-else
- SSH_AGENT="false"
-fi
-
-if [ $GIT_INSTALLED == "true" ]; then
- if [ $SSH_AGENT == "true" ]; then
- git pull || exit 1
- else
- git pull $http master || exit 1
- fi
-else
- # fallback on wgetting the tarball
- pushd ~
- wget --output-document dotfiles.tgz $tgz || exit 1
- tar -xzvf dotfiles.tgz || exit 1
- rm -rf dotfiles.tgz || exit 1
- popd
-fi