fix: setup and arty completion bugs

bin/setup:
- Fix Step 1 of 6 → Step 1 of 7
- exec zsh -l </dev/tty to avoid inheriting stale curl pipe on stdin
  (without /dev/tty the curl|sh pipe bytes re-run the script as zsh)
- Fall back to printing exec zsh hint when /dev/tty is unavailable
- Check completion file existence instead of trusting arty exit code

bin/arty:
- Fix cmd_completion returning exit 1 for zsh: last statement was
  [[ "$shell" == "bash" ]] which is false, changed to if/fi

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-22 16:26:13 +02:00
co-authored by Claude Sonnet 4.6
parent febcd99e35
commit 7f5991c1bd
2 changed files with 12 additions and 6 deletions
+3 -1
View File
@@ -1362,7 +1362,9 @@ cmd_completion() {
echo "$content" > "$dest"
log_success "$shell completion installed: $dest"
[[ "$shell" == "bash" ]] && log_info "Reload: source $dest"
if [[ "$shell" == "bash" ]]; then
log_info "Reload: source $dest"
fi
}
# USAGE AND HELP
+9 -5
View File
@@ -99,7 +99,7 @@ detect_os() {
# ─── Step 1: Prerequisites ────────────────────────────────────────────────────
check_prerequisites() {
step_header "Step 1 of 6 — Prerequisites"
step_header "Step 1 of 7 — Prerequisites"
detect_os
log_info "OS detected: ${BOLD}$OS${NC}"
@@ -310,7 +310,8 @@ install_completion() {
# arty completion zsh --install writes to the first writable fpath dir,
# defaulting to ~/.zsh/completions/_arty (which .zshenv/oh-my-zsh picks up).
if ! (cd "$HOME" && "$arty_bin" completion zsh --install); then
(cd "$HOME" && "$arty_bin" completion zsh --install) || true
if [[ ! -f "$HOME/.zsh/completions/_arty" ]]; then
log_warn "arty completion zsh --install failed — skipping."
fi
}
@@ -348,10 +349,13 @@ main() {
install_completion # Step 6
post_install # Step 7
# Hand off to zsh immediately — no need to exec zsh manually.
if command -v zsh >/dev/null 2>&1; then
exec zsh -l
# Hand off to a zsh login shell immediately.
# Read from /dev/tty so zsh gets the terminal, not the leftover pipe bytes
# from the curl|sh pattern (which still has the tail of this script buffered).
if command -v zsh >/dev/null 2>&1 && [[ -e /dev/tty ]]; then
exec zsh -l </dev/tty
fi
echo -e "${YELLOW}[!]${NC} Start a new shell session: ${BOLD}exec zsh${NC}"
}
main "$@"