[BUG] Shell snapshot's `hash rg` check expands a user alias named `hash`, wiping the clipboard on every Bash call

Status Open
Reported on v2.1.296
Maintainer reply None cached
Activity 1 comment · opened Oct 12, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The zsh shell snapshot restores the user's aliases. After that, it checks for ripgrep with this line:

if ! hash rg 2>/dev/null && ! typeset -f rg >/dev/null 2>&1; then

zsh expands aliases in the sourced snapshot. If the user has an alias named hash, the check runs that alias instead of the builtin. This happens on every Bash tool call, in every session.

My alias piped the output of a command to pbcopy. For hash rg, that output was empty. As a result, every Bash tool call set the macOS clipboard to an empty string. With four sessions open, the clipboard emptied every few seconds, in all apps.

What Should Happen?

Commands that Claude Code adds to the snapshot do not run user aliases. For example, builtin hash rg and command -v rg skip aliases. Another option is to run the check before the snapshot restores aliases.

Error Messages/Logs

Snapshot excerpt (`~/.claude/shell-snapshots/snapshot-zsh-<id>.sh`):


4602: alias -- hash=$'f() {\n  <command> "$1" 2>/dev/null \\\n    | awk ... \\\n    | pbcopy\n}; f'
...
4626: if ! hash rg 2>/dev/null && ! typeset -f rg >/dev/null 2>&1; then


Process tree caught during a Bash tool call:


<alias command> rg
└─ /bin/zsh -c source ~/.claude/shell-snapshots/snapshot-zsh-<id>.sh ...
   └─ claude


In the macOS unified log (`process == "pboard"`), each empty clipboard write came from a short-lived `pbcopy` process that wrote 0 bytes.

Steps to Reproduce

  1. Add this alias to ~/.zshrc:

``zsh
alias hash='echo "hash alias ran" >> /tmp/hash-alias.log; builtin hash'
``

  1. Start a new Claude Code session.
  2. Ask Claude to run any Bash command, for example ls.
  3. Run cat /tmp/hash-alias.log. The file has one line for each Bash tool call.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

Not known. I noticed the problem around 2026-10-05.

Claude Code Version

2.1.296 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

  • The bug is not specific to pbcopy. Any alias named hash runs on every Bash tool call, with its side effects.
  • My alias existed since February 2026. The clipboard problem started around 2026-10-05. The 2.1.290 changelog (released 2026-10-05) has "Fixed the Bash tool occasionally losing shell aliases, functions and plugin PATH entries for a whole session". I did not confirm a link to that change.
  • The alias in the steps is a minimal stand-in for my original alias. I tested it with the two snapshot lines in zsh, not in a fresh Claude Code session. I saw the original alias run in live sessions.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗