38 lines
1.0 KiB
Bash
Executable File
38 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
OMZ_DIR="${ZSH:-$HOME/.oh-my-zsh}"
|
|
OMZ_CUSTOM="${ZSH_CUSTOM:-$OMZ_DIR/custom}"
|
|
PLUGINS_DIR="$OMZ_CUSTOM/plugins"
|
|
|
|
clone_or_update_plugin() {
|
|
name="$1"
|
|
url="$2"
|
|
dest="$PLUGINS_DIR/$name"
|
|
|
|
if [ -d "$dest/.git" ]; then
|
|
# update existing plugin repo
|
|
git -C "$dest" pull --ff-only
|
|
elif [ -e "$dest" ]; then
|
|
# path exists but isn't a git repo (avoid clobbering)
|
|
echo "Skip: $dest exists but is not a git repo" >&2
|
|
else
|
|
git clone "$url" "$dest"
|
|
fi
|
|
}
|
|
|
|
# 1) Oh My Zsh: clone only if missing
|
|
if [ -d "$OMZ_DIR/.git" ]; then
|
|
: # OMZ already installed, do nothing
|
|
elif [ -e "$OMZ_DIR" ]; then
|
|
echo "Skip: $OMZ_DIR exists but is not a git repo" >&2
|
|
else
|
|
git clone https://github.com/ohmyzsh/ohmyzsh.git "$OMZ_DIR"
|
|
fi
|
|
|
|
# 2) Plugins: if present pull, else clone (requires OMZ dirs)
|
|
mkdir -p "$PLUGINS_DIR"
|
|
|
|
clone_or_update_plugin "zsh-autosuggestions" "https://github.com/zsh-users/zsh-autosuggestions"
|
|
clone_or_update_plugin "zsh-syntax-highlighting" "https://github.com/zsh-users/zsh-syntax-highlighting"
|