Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ bindkey '^x^e' edit-command-line

# cfi is find all ignoring .git
alias cfi='cd $(find . -type d -path "./.git" -prune -o -type d -not -path "*/\.*" -print | fzf --reverse --preview "ls --color {}")'
alias cldo="claude --dangerously-skip-permissions --model=opus $@"
alias clds="claude --dangerously-skip-permissions --model=sonnet $@"
alias cldk="claude --dangerously-skip-permissions --model=haiku $@"
Comment on lines +56 to +58
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

zsh alias $@ argument forwarding vs function

💡 Result:

In zsh, an alias is just textual substitution of the first word of a command line; it does not receive positional parameters, so $@ inside an alias does not mean “the alias’s arguments” (it either expands when the alias is defined or is treated literally, depending on quoting) and won’t forward what you type after the alias name. [1], [2], [3]

What to use instead: a function

Use a function when you need argument forwarding (or any real logic):

mycmd() {
  realcmd "$@"
}

"$@" expands to the arguments passed to the function call. [2]

When an alias “seems” to forward args

This works because the shell appends the extra words after the alias expansion:

alias ll='ls -l'
# `ll /tmp` becomes `ls -l /tmp`

But you still can’t inspect/rewrite/conditionally use those arguments from within an alias (no reliable $@ concept). [1]

If you tried something like this

alias ls='command -v lsd >/dev/null && lsd "$@" || ls "$@"'

That fails for the reason above: aliases aren’t functions, so they don’t have $@; make it a function (and usually do the detection once, at startup, if possible). [3]

Sources:
[1] Zsh Guide: aliases don’t take arguments; use functions (zsh.sourceforge.io) (zsh.sourceforge.io)
[2] Ask Different: use a function + "$@" to pass arguments (apple.stackexchange.com) (apple.stackexchange.com)
[3] Reddit explanation: “Aliases aren’t functions, they don’t have $@” (reddit.com) (reddit.com)

Citations:


Aliases won't forward invocation arguments; use functions instead.

These aliases attempt to forward arguments via $@, but in zsh, aliases perform only textual substitution and do not receive positional parameters. The $@ inside the alias text will not expand to the arguments passed when calling cldo, clds, or cldk.

Proposed fix
-alias cldo="claude --dangerously-skip-permissions --model=opus $@"
-alias clds="claude --dangerously-skip-permissions --model=sonnet $@"
-alias cldk="claude --dangerously-skip-permissions --model=haiku $@"
+cldo() { command claude --dangerously-skip-permissions --model=opus "$@"; }
+clds() { command claude --dangerously-skip-permissions --model=sonnet "$@"; }
+cldk() { command claude --dangerously-skip-permissions --model=haiku "$@"; }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
alias cldo="claude --dangerously-skip-permissions --model=opus $@"
alias clds="claude --dangerously-skip-permissions --model=sonnet $@"
alias cldk="claude --dangerously-skip-permissions --model=haiku $@"
cldo() { command claude --dangerously-skip-permissions --model=opus "$@"; }
clds() { command claude --dangerously-skip-permissions --model=sonnet "$@"; }
cldk() { command claude --dangerously-skip-permissions --model=haiku "$@"; }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.zshrc around lines 56 - 58, The aliases cldo, clds, and cldk won’t forward
runtime arguments because zsh aliases do textual substitution and don’t accept
positional parameters; replace each alias with a shell function (e.g., define
cldo(), clds(), cldk()) that invokes the claude command with the appropriate
--model value and forwards all invocation arguments using "$@"; update the
existing alias lines to function definitions that call claude
--dangerously-skip-permissions --model=opus/sonnet/haiku respectively and pass
"$@" so arguments are forwarded correctly.

# cf is find all - shell function wrapper for cf program
cf() {
local dir
Expand Down