Biggest update to setup.sh since the invention of bread
- Add a few items to skipitems that were missing - Add a matches_skip_item function that checks if a basename matches one of the skip items - Clean up files that match skipitems - Add a +v arg that disables installing Vim modules
This commit is contained in:
parent
386b88ee9e
commit
af9bc505bb
1 changed files with 62 additions and 29 deletions
65
setup.sh
65
setup.sh
|
@ -1,9 +1,9 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
dfdir=$(cd "$(dirname "$0")" && pwd)
|
dotfiles_dir=$(cd "$(dirname "$0")" && pwd)
|
||||||
sys=`uname -s | tr A-Z a-z`
|
sys=`uname -s | tr A-Z a-z`
|
||||||
|
|
||||||
skipitems=(setup.sh README.md py Colors LaunchAgents)
|
skipitems=(setup.sh README.md py bin Alfred Colors Dotfiles LaunchAgents '.*\.orig' '.*~')
|
||||||
|
|
||||||
typeset -A vimbundles
|
typeset -A vimbundles
|
||||||
vimbundles=(Vundle.vim "https://github.com/gmarik/Vundle.vim.git")
|
vimbundles=(Vundle.vim "https://github.com/gmarik/Vundle.vim.git")
|
||||||
|
@ -29,8 +29,20 @@ function link {
|
||||||
printf " %8s: %s\n" $action "$dest"
|
printf " %8s: %s\n" $action "$dest"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function matches_skip_item {
|
||||||
|
local string_to_match=$1
|
||||||
|
|
||||||
|
for item in $skipitems; do
|
||||||
|
if [[ $string_to_match =~ $item ]]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
print -P " %BHome:%b $HOME"
|
print -P " %BHome:%b $HOME"
|
||||||
print -P " %BDotfiles:%b $dfdir"
|
print -P " %BDotfiles:%b $dotfiles_dir"
|
||||||
print -P "%BSkip Items:%b $skipitems\n"
|
print -P "%BSkip Items:%b $skipitems\n"
|
||||||
|
|
||||||
print -P "%BRemoving stray dotfile symlinks from $HOME%b"
|
print -P "%BRemoving stray dotfile symlinks from $HOME%b"
|
||||||
|
@ -45,13 +57,15 @@ for file in ~/.?*; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
link_dirname=`dirname "$link_dest"`
|
link_dirname=`dirname "$link_dest"`
|
||||||
if [[ "$link_dirname" != "$dfdir" ]]; then
|
if [[ "$link_dirname" != "$dotfiles_dir" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ! matches_skip_item `basename "$link_dest"`; then
|
||||||
if [[ -e "$link_dest" ]]; then
|
if [[ -e "$link_dest" ]]; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
printf " Removing: %s\n" "$file"
|
printf " Removing: %s\n" "$file"
|
||||||
rm "$file"
|
rm "$file"
|
||||||
|
@ -63,26 +77,29 @@ if [[ $did_remove_at_least_one_symlink -ne 1 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print -P "%BSymlinking config files%b"
|
print -P "%BSymlinking config files%b"
|
||||||
local dotfile
|
|
||||||
local did_link_at_least_one_dotfile=0
|
local did_link_at_least_one_dotfile=0
|
||||||
for dotfile in $dfdir/*; do
|
for dotfile in $dotfiles_dir/*; do
|
||||||
if [[ ${skipitems[(r)$dotfile]} == $dotfile ]]; then
|
local dotfile_basename=`basename "$dotfile"`
|
||||||
|
|
||||||
|
if matches_skip_item "$dotfile_basename"; then
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [[ "`basename $dotfile`" == "config" ]]; then
|
|
||||||
|
if [[ "$dotfile_basename" == "config" ]]; then
|
||||||
# Recurse into config and link each item individually
|
# Recurse into config and link each item individually
|
||||||
mkdir -p "$HOME/.config"
|
mkdir -p "$HOME/.config"
|
||||||
for config_dotfile in $dfdir/config/*; do
|
for config_dotfile in $dotfiles_dir/config/*; do
|
||||||
config_dotfile_basename=`basename "$config_dotfile"`
|
config_dotfile_basename=`basename "$config_dotfile"`
|
||||||
link "$config_dotfile" "$HOME/.config/$config_dotfile_basename"
|
link "$config_dotfile" "$HOME/.config/$config_dotfile_basename"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
link "$dotfile"
|
link "$dotfile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
did_link_at_least_one_dotfile=1
|
did_link_at_least_one_dotfile=1
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -f "$HOME/.hushlogin" ]]; then
|
if [[ ! -f "$HOME/.hushlogin" ]]; then
|
||||||
print " touch $HOME/.hushlogin"
|
print " touch $HOME/.hushlogin"
|
||||||
touch "$HOME/.hushlogin"
|
touch "$HOME/.hushlogin"
|
||||||
did_link_at_least_one_dotfile=1
|
did_link_at_least_one_dotfile=1
|
||||||
|
@ -92,9 +109,22 @@ if [[ $did_link_at_least_one_dotfile -ne 1 ]]; then
|
||||||
print " Nothing to link"
|
print " Nothing to link"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local install_vim_modules=1
|
||||||
|
while getopts "v" arg $@; do
|
||||||
|
case $arg in
|
||||||
|
"v") install_vim_modules=1 ;;
|
||||||
|
"+v") install_vim_modules=0 ;;
|
||||||
|
*)
|
||||||
|
echo "Usage: setup.sh [+v|-v]"
|
||||||
|
echo " +v|-v Install Vim modules"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
print -P "%BFetching Vim modules%b"
|
print -P "%BFetching Vim modules%b"
|
||||||
cd "$dfdir/vim/bundle"
|
if (( $install_vim_modules )); then
|
||||||
for module in ${(k)vimbundles}; do
|
cd "$dotfiles_dir/vim/bundle"
|
||||||
|
for module in ${(k)vimbundles}; do
|
||||||
print -n " $module"
|
print -n " $module"
|
||||||
|
|
||||||
if [[ ! -d $module ]]; then
|
if [[ ! -d $module ]]; then
|
||||||
|
@ -105,12 +135,15 @@ for module in ${(k)vimbundles}; do
|
||||||
result='failed'
|
result='failed'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
VIM=nvim
|
VIM=nvim
|
||||||
if ! whence -cp nvim >& -; then
|
if ! whence -cp nvim >& -; then
|
||||||
VIM=vim
|
VIM=vim
|
||||||
|
fi
|
||||||
|
$VIM +PluginInstall +qall
|
||||||
|
else
|
||||||
|
print " Nothing to do"
|
||||||
fi
|
fi
|
||||||
$VIM +PluginInstall +qall
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue