From d757869b6fead59b147afac8236a05d3b6c9613d Mon Sep 17 00:00:00 2001 From: sailor Date: Wed, 3 Jun 2026 23:18:21 +0100 Subject: [PATCH] fix: handle existing nvim config dir --- install.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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"