Skip to content

Commit 3e39ad6

Browse files
committed
fix: preserve working directory after update-zush reload
1 parent bb9e454 commit 3e39ad6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/update-check.zsh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ typeset -g ZUSH_UPDATE_CHECK_FILE="${ZUSH_CACHE_DIR}/last-update-check"
88
typeset -g ZUSH_UPDATE_AVAILABLE_FILE="${ZUSH_CACHE_DIR}/update-available"
99

1010
# Reload the current interactive shell with fresh Zush config
11+
# Optional: pass directory to change to before exec
1112
_zush_reload_shell() {
1213
# Require an interactive session with a TTY
1314
[[ ! -o interactive || ! -t 1 ]] && return 1
1415

1516
local shell_bin="${ZSH_BINARY:-}" \
16-
shell_path=""
17+
shell_path="" \
18+
target_dir="${1:-}"
1719

1820
if [[ -n "$shell_bin" && -x "$shell_bin" ]]; then
1921
shell_path="$shell_bin"
@@ -23,6 +25,11 @@ _zush_reload_shell() {
2325

2426
[[ -z "$shell_path" ]] && return 1
2527

28+
# Change to target directory if provided
29+
if [[ -n "$target_dir" && -d "$target_dir" ]]; then
30+
cd "$target_dir" 2>/dev/null || true
31+
fi
32+
2633
echo " Reloading shell with latest Zush..."
2734
exec -l "$shell_path"
2835
}
@@ -138,7 +145,7 @@ _zush_do_update() {
138145
if git pull --quiet 2>/dev/null; then
139146
echo " ✅ Zush updated successfully!"
140147
rm -f "$ZUSH_UPDATE_AVAILABLE_FILE"
141-
if ! _zush_reload_shell; then
148+
if ! _zush_reload_shell "$current_dir"; then
142149
echo " Restart your shell to use the latest version."
143150
fi
144151
else

0 commit comments

Comments
 (0)