72 lines
2.0 KiB
Bash
Executable File
72 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
error() {
|
|
echo "error: $*"
|
|
exit 1
|
|
}
|
|
|
|
directories=(
|
|
~/.cache/zsh
|
|
~/.local/bin
|
|
~/.local/share/zsh/plugins
|
|
~/.local/share/zsh/site-functions
|
|
)
|
|
for directory in $directories; do
|
|
mkdir -p $directory
|
|
done
|
|
|
|
plugins=(
|
|
zsh-users/zsh-autosuggestions
|
|
zsh-users/zsh-history-substring-search
|
|
zsh-users/zsh-syntax-highlighting
|
|
zsh-users/zsh-completions
|
|
)
|
|
for plugin in $plugins; do
|
|
plugin_directory=~/.local/share/zsh/plugins/${plugin/*\//}
|
|
if [ -d $plugin_directory ]; then
|
|
if ! git -C $plugin_directory diff-index --quiet HEAD --; then
|
|
error $plugin_directory contains unstaged changes
|
|
fi
|
|
pull=`git -C $plugin_directory pull`
|
|
if [ "$pull" != "Already up-to-date." ]; then
|
|
echo changed
|
|
fi
|
|
else
|
|
git clone https://github.com/$plugin.git $plugin_directory > /dev/null
|
|
echo changed
|
|
fi
|
|
done
|
|
|
|
declare -A symlinks
|
|
symlinks=(
|
|
~/.config/zsh/zlogin ~/.zlogin
|
|
~/.config/zsh/zlogout ~/.zlogout
|
|
~/.config/zsh/zprofile ~/.zprofile
|
|
~/.config/zsh/zshenv ~/.zshenv
|
|
~/.config/zsh/zshrc ~/.zshrc
|
|
~/.config/zsh/prompt_fresh_setup
|
|
~/.local/share/zsh/site-functions/prompt_fresh_setup
|
|
~/.config/zsh/build/_build-dir ~/.local/share/zsh/site-functions/_build-dir
|
|
~/.config/zsh/sandbox/_sandbox ~/.local/share/zsh/site-functions/_sandbox
|
|
~/.config/zsh/layout/_layout ~/.local/share/zsh/site-functions/_layout
|
|
~/.config/zsh/notes/_note ~/.local/share/zsh/site-functions/_note
|
|
~/.config/zsh/cmake-uninstall ~/.local/bin/cmake-uninstall
|
|
~/.config/zsh/$ ~/.local/bin/$
|
|
~/.config/zsh/url/url ~/.local/bin/url
|
|
~/.config/zsh/url/_url ~/.local/share/zsh/site-functions/_url
|
|
)
|
|
for source in ${(k)symlinks}; do
|
|
dest=$symlinks[$source]
|
|
if [ -L $dest ]; then
|
|
target=`readlink $dest`
|
|
if [ "$target" != "$source" ]; then
|
|
error symlink failed $dest exists but links to $target not $source
|
|
fi
|
|
elif [ -f $dest ]; then
|
|
error symlink failed $dest exists but is a regular file
|
|
else
|
|
ln -s $source $dest
|
|
echo changed
|
|
fi
|
|
done
|