Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 631e192430
Fetching contributors…

Cannot retrieve contributors at this time

executable file 164 lines (152 sloc) 4.558 kB
#!/usr/bin/env bash
# netj's dotfiles installer
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2006-05-21
set -e
cd ~/.dotfiles || . update
# install symlinks
install() {
local d=$1
local src=${2:-$d}
local nosymlink=${3:-false}
local nobackup=${4:-false}
local n=$(shname "$d")
# compute relative path
local rel=
case $d in
*/*) # need relative path to .dotfiles if path has depth
local dd=$(dirname "$d")
mkdir -p ~/"$dd"
rel=$(tr / '\n' <<<"$dd" |
sed -n '/^$/d; s/.*/../p' |
tr '\n' /)
;;
esac
# check if our link is already there
if [ ~/"$d" -ef "$src" ]; then
run ${n}_before "$@"
echo "$d installed"
run ${n}_after "$@"
else
if read -p "install $d? " -n1; then
echo
case "$REPLY" in
[Yy])
run ${n}_before "$@"
# backup previous one
! [ -e ~/"$d" ] || $nobackup || mv -iv ~/"$d" ~/"$d"~
# create a symlink or a hardlink
if $nosymlink; then
ln -fv "$src" ~/"$d"
else
ln -snfv "$rel.dotfiles/$src" ~/"$d"
fi
run ${n}_after "$@"
;;
esac
fi
fi
}
shname() {
local n=$1
# sanitize name
n=${n#.}
n=${n//[\/. -]/_}
echo "$n"
}
run() { [ "`type -t $1 2>/dev/null`" != function ] || (cd; "$@"); }
safeln() {
local src=$1; shift
local tgt=
for tgt in "$@"; do
if [ -e "$tgt" ]; then
[ "`readlink "$tgt"`" != "$src" ] || continue
mv -iv "$tgt" "$tgt~"
fi
[ -e "$tgt" ] || ln -sfnv "$src" "$tgt"
done
}
# core
bash_after() {
# .bash{rc,_profile} symlinks
(cd
safeln .bash/profile .bash{rc,_profile}
safeln .bash/logout .bash_logout
plugins=(
bash_completion
alias_completion
environment
prompt
xtermtitle
try+repeat
auto-tmux
git-helper
)
. .bash/plugins/bpm.sh enable "${plugins[@]}"
)
}
install .bash
install .inputrc
vim_after() { make -C .vim; }
install .vimrc
install .vim
install .tmux.conf
install .screenrc
install .toprc
emacs_d_elisp_Makefile_after() { make -C .emacs.d/elisp; }
install .emacs
install .emacs.d/elisp/Makefile
# GUI
fonts_after() { make -C .fonts; }
install .fonts.conf
install .fonts
# Mac OS X
case $(uname) in Darwin)
# install applescripts
scptd=Mac/Scripts/compiled/
mkdir -p "$scptd"
compilescpt() {
local o=$1 s="$2"
cd ./.dotfiles
local n=$(shname "$o")
run ${n}_before "$@"
! [ "$o" -nt "$s" ] || return 0
echo "$o: compiling ${s##*/}"
mkdir -p "$(dirname "$o")"
xattr -w com.apple.TextEncoding 'UTF-8;134217984' "$s"
osacompile -x -o "$o" "$s"
}
installscpt() {
local src=$1
local srcrel=${src#Mac/Scripts/}
local obj="$scptd${srcrel%.applescript}".scpt
local dst=Library/Scripts/"${obj#$scptd}"
local n=$(shname "$dst")
[ x"$(type -t ${n}_before)" = x"function" ] ||
eval "${n}_before() { compilescpt '${obj//\'/\'\\\'\'}' '${src//\'/\'\\\'\'}'; }" # TODO escape obj and src
install "$dst" "$obj" true true
}
Mac_Scripts_compiled_Applications_Finder_lselect_scpt_before() {
! [ -e .dotfiles/Mac/Scripts/Applications/Finder/lselect.applescript ] || return 0
curl -RLo .dotfiles/Mac/Scripts/Applications/Finder/lselect.applescript http://anoved.net/files/lselect.applescript
}
Library_Scripts_Applications_iTunes_iTunes_SED_scpt_before() {
! [ -e .dotfiles/"$scptd"/Applications/iTunes/iTunes\ SED.scpt ] || return 0
curl -RLO http://aurelio.googlecode.com/files/iTunes_SED-1.1.zip
ditto -xk iTunes_SED-*.zip .dotfiles/"$scptd"/Applications/iTunes/
rm -f iTunes_SED-*.zip
}
for s in Mac/Scripts/{*,Applications/{*/*,Finder/lselect,iTunes/iTunes\ SED}}.applescript; do
[ -e "$s" ] || continue
installscpt "$s"
done
for s in Mac/Scripts/*.sh; do
[ -e "$s" ] || continue
install Library/"${s#Mac/}" "$s" true true
done
# install KeyRemap4MacBook settings
for xml in Mac/KeyRemap4MacBook/*.xml; do
[ -e "$xml" ] || continue
install Library/"Application Support"/"${xml#Mac/}" "$xml"
done
;; esac
Jump to Line
Something went wrong with that request. Please try again.