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-01-23 11:27:16 -08:00
|
|
|
print -P "%B Home:%b $HOME"
|
|
|
|
print -P "%BDotfiles:%b $dfdir\n"
|
|
|
|
|
|
|
|
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
|
|
|
|
link "$dotfile"
|
|
|
|
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
|
|
|
|
2013-09-04 14:03:45 -07:00
|
|
|
if [[ -d $module ]]; then
|
2016-02-07 11:22:33 -08:00
|
|
|
# result='skipped'
|
2012-08-08 10:10:57 -07:00
|
|
|
else
|
|
|
|
git clone ${vimbundles[$module]} $module 1>/dev/null 2>&1
|
|
|
|
if [[ $? -eq 0 ]]; then
|
|
|
|
result='done'
|
|
|
|
else
|
|
|
|
result='failed'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
spaces=''
|
|
|
|
filler=$(($COLUMNS - ${#module} - ${#result} - 4))
|
|
|
|
for (( i=0; $i < $filler; i++ )); do spaces="$spaces "; done
|
|
|
|
if [[ $result == 'skipped' ]]; then
|
|
|
|
color='yellow'
|
|
|
|
elif [[ $result == 'failed' ]]; then
|
|
|
|
color='red'
|
|
|
|
elif [[ $result == 'done' ]]; then
|
|
|
|
color='green'
|
|
|
|
fi
|
|
|
|
print -P "$spaces%F{$color}$result%f"
|
|
|
|
done
|
2011-05-03 21:53:50 -07:00
|
|
|
|
2018-04-15 19:14:41 -07:00
|
|
|
vim +PluginInstall +qall
|
|
|
|
|
2011-05-03 21:53:50 -07:00
|
|
|
exit 0
|