From 76aadda1fdcb58e4c2280fc212b94fd03d5fd1c1 Mon Sep 17 00:00:00 2001 From: Jeremy McClure Date: Sat, 1 Aug 2026 16:48:19 -0400 Subject: [PATCH] fix: restore original dir before exec zsh --- default/.config/zsh/functions.zsh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/default/.config/zsh/functions.zsh b/default/.config/zsh/functions.zsh index 8c49e8c..b1abeeb 100644 --- a/default/.config/zsh/functions.zsh +++ b/default/.config/zsh/functions.zsh @@ -18,16 +18,21 @@ dotstate_update() { [[ "$(id -u)" -ne "$(stat -c '%u' "$TARGET_DIR" 2>/dev/null)" ]] && return 0 [[ ! -d "$TARGET_DIR/.git" ]] && return 0 + local orig_dir="$PWD" cd "$TARGET_DIR" || return 0 local remote_sha local_sha remote_sha=$(timeout 5 git ls-remote "$REPO_URL" HEAD | awk '{print $1}') - [[ -z "$remote_sha" ]] && return 0 + [[ -z "$remote_sha" ]] && { cd "$orig_dir"; return 0; } local_sha=$(git rev-parse HEAD) - [[ "$remote_sha" == "$local_sha" ]] && return 0 + if [[ "$remote_sha" == "$local_sha" ]]; then + cd "$orig_dir" + return 0 + fi info "Repository out of date. Pulling updates..." git fetch origin && git reset --hard origin/master && git clean -fd &>/dev/null + cd "$orig_dir" dotstate activate exec zsh } \ No newline at end of file