Skip to content

fix(install): sync the hook scripts with the CLI and name the user's shell in the next steps - #17

Merged
AnnatarHe merged 1 commit into
mainfrom
claude/zen-faraday-d7h1m7
Nov 10, 2026
Merged

AnnatarHe merged 1 commit into
mainfrom
claude/zen-faraday-d7h1m7

Conversation

@AnnatarHe

@AnnatarHe AnnatarHe commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Changes

hooks/: copied from the CLI's embedded hooks (model/hooks/ in shelltime/cli). They had drifted behind, so curl installs got older scripts until shelltime init rewrote them:

  • bash and zsh recorded the previous command again when Enter was pressed on an empty line;
  • fish ran gc and track on the terminal's input while fish was still probing the terminal at startup.

install.bash: the last message names the user's own shell, taken from $SHELL, which is the login shell also under curl | bash:

Next steps:
  1. Open a new terminal, or reload this one:  source ~/.bashrc
  2. Run:  shelltime init

An unknown or empty $SHELL gets the old three-file wording. Users were running shelltime init in a shell that didn't have it on PATH yet (shelltime: command not found).

CLAUDE.md notes that hooks/ are copies of the CLI's hooks and must change together.

Testing

  • bash -n install.bash and bash -n hooks/bash.bash; cmp shows the three hook files are byte-identical to the CLI's.
  • Checked the reload command for SHELL set to bash, zsh, fish, /bin/sh and empty.

Companion to the shelltime/cli change that quiets shelltime init, skips shells the user doesn't have, and makes gc tell users to run shelltime init before setup.


Generated by Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…shell in the next steps

- hooks/: copy the CLI's embedded hooks (shelltime/cli model/hooks).
  Curl installs got older scripts until `shelltime init` rewrote them:
  bash and zsh recorded the previous command again on an empty Enter,
  and fish ran gc and track on the terminal's input while it was still
  probing the terminal.
- install.bash: the reload step names the user's own shell config from
  $SHELL (`source ~/.bashrc`) and offers opening a new terminal, so
  `shelltime init` isn't run in a shell that doesn't have it on PATH yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014EpZRgMC528MvzhF6oiKHo
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-10T14:58:38.928657Z 3c0a494 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@shelltime

shelltime Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

☁️ Claude Code cloud · Refine shell initialization and hook installation UX

Improved shell hook installation UX by directing uninitialized users to shelltime init, reducing default output, and ignoring unavailable-shell hook failures.

💰 Cost 🔢 Tokens ⏱️ Duration 🧠 Model 💬 Prompts ✏️ Lines
$8.48 21.2M 44m (18m active) claude-opus-5-5 6 +176 / −33

21.2M tokens: 171 input · 95.5K output · 20.8M cache read · 300.4K cache write

📝 AI summary

Reviewed the CLI and installation flows, proposed a plan, and updated /home/user/cli/commands/hooks.install.go. The hook installation behavior now gives actionable guidance to run shelltime init when initialization is required, while reducing noisy output during normal initialization. Zsh and Fish hook installation failures are treated as ignorable when those shells are not available, avoiding false errors for Bash-only users.

Also removed the unnecessary privacy and opt-out messaging, added support for init --verbose so detailed output remains available on demand, and synchronized the installation hook scripts with the revised CLI behavior. Bash commands were used to inspect and validate the relevant implementation and installation flow.

View this session on ShellTime →

Updated 2026-11-11 14:58 UTC by ShellTime · totals for the whole session so far · the session page is visible to its owner

Copy link
Copy Markdown
Contributor Author

/claude review


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

@claude review


Generated by Claude Code

@claude

claude Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Claude finished @AnnatarHe's task in 19s —— View job


Review of PR #17

I read the full diff against origin/main and the surrounding bash hook. I didn't run anything, including the CI matrix. No blocking issues.

  • Read the diff and the surrounding hook code
  • Checked each change

hooks/bash.bash: Correct. precmd_invoke_cmd now clears LAST_COMMAND after reading it. The existing -z "$CMD" guard then skips the post-track on an empty prompt. The trailing newline is also fixed.

hooks/zsh.zsh: Correct. _SHELLTIME_LAST_CMD is set in preexec and consumed in precmd, which replaces fc -ln -1. The early return on an empty value stops a blank Enter from re-recording the previous history entry. It also skips the post-track at shell startup. One side effect: preexec sets the variable before the shelltime self-tracking skip, but precmd filters those commands again, so that's harmless.

hooks/fish.fish: Redirecting stdin from /dev/null for gc and track fixes the terminal-probe contention. Adding 2>&1 also silences stderr from track. That's reasonable for a hook, but errors from a broken CLI will no longer show up.

install.bash: The $SHELL-based case is sound. ${SHELL:-} is safe under set -u, and the fallback keeps the old three-file wording. Two small notes, neither blocking:

  • On macOS, a bash user's login shell may read ~/.bash_profile, not ~/.bashrc. This depends on what the installer wrote to. If it only writes ~/.bashrc, the message matches.
  • $SHELL is the login shell, not necessarily the shell running the terminal. That's fine, since the message also says to open a new terminal.

CLAUDE.md: The note that hooks/ mirrors the CLI's embedded hooks is useful. The cloud-related paragraph above it is unchanged.

Summary: The change is safe to merge. The PR says the hook files are byte-identical to the CLI's. I couldn't check that from this repo, so it's worth re-running cmp against the CLI's model/hooks/ once more before merging.
· branch claude/zen-faraday-d7h1m7

@AnnatarHe
AnnatarHe merged commit 66f6cc8 into main Nov 10, 2026
3 of 9 checks passed
@AnnatarHe
AnnatarHe deleted the claude/zen-faraday-d7h1m7 branch November 10, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants