Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 98 lines (83 sloc) 2.43 KB
#!/bin/sh
set -o errexit
set -o nounset
# Get the full path to the current directory.
cwd=$(pwd)
cd $(dirname $0)
root=$(pwd)
cd ${cwd}
# Symlink a bash completion file
bash_completion() {
completion_file=$1
completion_dir=/etc/bash_completion.d
if which brew > /dev/null 2>&1; then
completion_dir="$(brew --prefix)${completion_dir}"
fi
symlink ${completion_file} ${completion_dir}/$(basename ${completion_file})
}
# Print the command we're going to run and (if DRY_RUN is not set) run it.
cmd() {
echo $*
$*
}
# Symlink a file from this repo.
symlink() {
file=$1
if [ $# -gt 1 ]; then
target=$2
if [ "$(echo ${target} | grep ^/)" != "${target}" ]; then
target=${HOME}/${target}
fi
else
target=${HOME}/${file}
fi
if [ "$(echo ${file} | grep ^/)" != "${file}" ]; then
file="${root}/${file}"
fi
if [ ! -L ${target} ] || [ $(readlink ${target}) != ${file} ]; then
cmd ln -fns ${file} ${target}
fi
}
#
# Now work through all the things we need.
#
# Install homebrew
if ! which brew > /dev/null 2>&1; then
cmd ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
brew install python
pip install cider
# Generate .gitconfig
sed -e s/___EMAIL___/$(git config user.email || echo ross.duggan@acm.org)/ ${root}/.gitconfig.template > ${HOME}/.gitconfig
# Now link in the dotfiles
symlink .bash_login
symlink .bash_profile
symlink .git-prompt
symlink .cvsignore
symlink .inputrc
symlink .vim
symlink .vimrc
symlink .cider
cider restore
# Extra bash completions
bash_completion modules/completion-ruby/completion-bundle
bash_completion modules/completion-ruby/completion-gem
bash_completion modules/completion-ruby/completion-jruby
bash_completion modules/completion-ruby/completion-rails
bash_completion modules/completion-ruby/completion-rake
bash_completion modules/completion-ruby/completion-ruby
bash_completion modules/vagrant-bash-completion/vagrant
bash_completion $(brew --prefix)/Library/Contributions/brew_bash_completion.sh
# Prune the bash completions to the things we have
completion_dir=/etc/bash_completion.d
if which brew > /dev/null 2>&1; then
completion_dir="$(brew --prefix)${completion_dir}"
fi
for _completion_file in $(find ${completion_dir} -type l -o -type f); do
_have=$(awk '/^have / { print $2; exit}' ${_completion_file})
if [ -n "${_have}" ]; then
if ! type ${_have} > /dev/null 2>&1; then
cmd rm ${_completion_file}
fi
fi
done