Skip to content

Commit 462eba1

Browse files
fix(zsh): stop aliasing grep to rg in interactive shells
`alias grep='rg'` made standard grep invocations silently change meaning: rg is not a drop-in grep replacement. The most common breakage is flags — `grep -E` means extended regex, but rg's `-E` is --encoding, so a copied command like `grep -E '^ClientAlive(Interval|CountMax)' /etc/ssh/sshd_config` fails with "unknown encoding". This breaks pasted support/debugging commands and coding agents (e.g. Codex) that emit POSIX/GNU grep when they intend grep semantics and already call `rg` explicitly when they want ripgrep. This matches the existing principle in the same file for fd ("NOT aliased over 'find' — fd has incompatible syntax"). Replaced the shadowing alias with non-shadowing convenience aliases `rgrep`/`search` for ripgrep. Closes #303 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 2285968 commit 462eba1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

acfs/zsh/acfs.zshrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,13 @@ if command -v fd &>/dev/null; then
133133
elif command -v fdfind &>/dev/null; then
134134
alias fd='fdfind'
135135
fi
136-
command -v rg &>/dev/null && alias grep='rg'
136+
# ripgrep as standalone aliases (NOT aliased over 'grep' — rg is not a drop-in
137+
# replacement: e.g. grep's -E means ERE while rg's -E means --encoding, so
138+
# `grep -E 'pat' file` breaks under an alias. Same principle as fd/find above.)
139+
if command -v rg &>/dev/null; then
140+
alias rgrep='rg'
141+
alias search='rg'
142+
fi
137143
command -v dust &>/dev/null && alias du='dust'
138144
command -v btop &>/dev/null && alias top='btop'
139145
command -v nvim &>/dev/null && alias vim='nvim'

0 commit comments

Comments
 (0)