2013-09-04 14:03:45 -07:00
|
|
|
#!/usr/bin/env zsh
|
2011-05-03 21:53:50 -07:00
|
|
|
|
|
|
|
dfdir=$(cd "$(dirname "$0")" && pwd)
|
2012-04-23 15:02:41 -07:00
|
|
|
sys=`uname -s | tr A-Z a-z`
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2022-01-23 11:27:16 -08:00
|
|
|
skipitems=(setup.sh README.md py Colors LaunchAgents)
|
2013-01-23 11:11:52 -08:00
|
|
|
|
2012-08-08 10:10:57 -07:00
|
|
|
typeset -A vimbundles
|
2022-01-23 11:27:16 -08:00
|
|
|
vimbundles=(Vundle.vim "https://github.com/gmarik/Vundle.vim.git")
|
2013-01-23 11:11:52 -08:00
|
|
|
|
2022-01-23 11:27:16 -08:00
|
|
|
function link {
|
|
|
|
local action
|
2014-09-02 09:37:45 -07:00
|
|
|
local dest
|
2022-01-23 11:27:16 -08:00
|
|
|
|
|
|
|
if [[ -z $2 ]]; then
|
|
|
|
local dotfile_basename=`basename "$1"`
|
|
|
|
dest="$HOME/.$dotfile_basename"
|
2014-09-02 09:37:45 -07:00
|
|
|
else
|
|
|
|
dest="$2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -e "$dest" ]]; then
|
|
|
|
action='Linking'
|
|
|
|
ln -fs "$1" "$dest"
|
|
|
|
else
|
|
|
|
action='Skipping'
|
|
|
|
fi
|
2022-01-23 11:27:16 -08:00
|
|
|
|
|
|
|
printf " %8s: %s\n" $action "$dest"
|
2014-09-02 09:37:45 -07:00
|
|
|
}
|
|
|
|
|
2022-05-28 23:58:47 -07:00
|
|
|
print -P " %BHome:%b $HOME"
|
|
|
|
print -P " %BDotfiles:%b $dfdir"
|
|
|
|
print -P "%BSkip Items:%b $skipitems\n"
|
2022-01-23 11:27:16 -08:00
|
|
|
|
|
|
|
print -P "%BRemoving stray dotfile symlinks from $HOME%b"
|
|
|
|
local link_dest
|
|
|
|
local link_dirname
|
|
|
|
local did_remove_at_least_one_symlink=0
|
|
|
|
for file in ~/.?*; do
|
|
|
|
link_dest=`readlink "$file"`
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
|
|
# Not a symlink.
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
link_dirname=`dirname "$link_dest"`
|
|
|
|
if [[ "$link_dirname" != "$dfdir" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -e "$link_dest" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
printf " Removing: %s\n" "$file"
|
|
|
|
rm "$file"
|
|
|
|
did_remove_at_least_one_symlink=1
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $did_remove_at_least_one_symlink -ne 1 ]]; then
|
|
|
|
print " Nothing to remove"
|
|
|
|
fi
|
2014-09-02 09:37:45 -07:00
|
|
|
|
2012-04-11 09:54:43 -07:00
|
|
|
print -P "%BSymlinking config files%b"
|
2022-01-23 11:27:16 -08:00
|
|
|
local dotfile
|
|
|
|
local did_link_at_least_one_dotfile=0
|
|
|
|
for dotfile in $dfdir/*; do
|
|
|
|
if [[ ${skipitems[(r)$dotfile]} == $dotfile ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2022-05-28 23:58:47 -07:00
|
|
|
if [[ "`basename $dotfile`" == "config" ]]; then
|
|
|
|
# Recurse into config and link each item individually
|
|
|
|
mkdir -p "$HOME/.config"
|
|
|
|
for config_dotfile in $dfdir/config/*; do
|
|
|
|
config_dotfile_basename=`basename "$config_dotfile"`
|
|
|
|
link "$config_dotfile" "$HOME/.config/$config_dotfile_basename"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
link "$dotfile"
|
|
|
|
fi
|
2022-01-23 11:27:16 -08:00
|
|
|
did_link_at_least_one_dotfile=1
|
2012-04-11 09:54:43 -07:00
|
|
|
done
|
|
|
|
|
2022-01-23 11:27:16 -08:00
|
|
|
if [[ -f "$HOME/.hushlogin" ]]; then
|
|
|
|
print " touch $HOME/.hushlogin"
|
|
|
|
touch "$HOME/.hushlogin"
|
|
|
|
did_link_at_least_one_dotfile=1
|
|
|
|
fi
|
2014-09-02 09:37:45 -07:00
|
|
|
|
2022-01-23 11:27:16 -08:00
|
|
|
if [[ $did_link_at_least_one_dotfile -ne 1 ]]; then
|
|
|
|
print " Nothing to link"
|
|
|
|
fi
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2012-08-08 10:10:57 -07:00
|
|
|
print -P "%BFetching Vim modules%b"
|
|
|
|
cd "$dfdir/vim/bundle"
|
|
|
|
for module in ${(k)vimbundles}; do
|
2022-01-23 11:27:16 -08:00
|
|
|
print -n " $module"
|
2012-08-08 10:10:57 -07:00
|
|
|
|
2022-05-28 23:58:47 -07:00
|
|
|
if [[ ! -d $module ]]; then
|
|
|
|
git clone ${vimbundles[$module]} $module >& -
|
2012-08-08 10:10:57 -07:00
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
result='done'
|
|
|
|
else
|
|
|
|
result='failed'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2022-05-28 23:58:47 -07:00
|
|
|
VIM=nvim
|
|
|
|
if ! whence -cp nvim >& -; then
|
|
|
|
VIM=vim
|
|
|
|
fi
|
|
|
|
$VIM +PluginInstall +qall
|
2018-04-15 19:14:41 -07:00
|
|
|
|
2011-05-03 21:53:50 -07:00
|
|
|
exit 0
|