diff --git a/install.sh b/install.sh index 476361f..d93eb33 100755 --- a/install.sh +++ b/install.sh @@ -1,3 +1,20 @@ #!/bin/sh # Installs the Neovim config only; Neovim itself must already be installed. -mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}" && git clone https://git.sailorpunisher.com/sailor/nvim-config.git "${XDG_CONFIG_HOME:-$HOME/.config}/nvim" +set -eu + +repo_url='https://git.sailorpunisher.com/sailor/nvim-config.git' +target="${XDG_CONFIG_HOME:-$HOME/.config}/nvim" + +mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}" + +if [ -d "$target/.git" ]; then + git -C "$target" pull --ff-only + exit 0 +fi + +if [ -e "$target" ]; then + backup="${target}.bak-$(date +%Y%m%d-%H%M%S)" + mv "$target" "$backup" +fi + +git clone "$repo_url" "$target"